The day Devaki and Vasudeva got married, a voice from the sky was heard prophesying that Devaki's eighth son will bring an end to Kansa’s rule and will kill him. Frightened Kansa immediately unsheathed his sword to kill his sister but Vasudeva intervened and implored Kansa to spare her. He promised to handover every child born to Kansa. Kansa relented but imprisoned the couple. He then vowed that he will kill every child of Devaki and Vasudeva.
Seeing their first seven children being killed by the cruel Kansa, the imprisoned couple feared giving birth to their eighth child. Lord Vishnu appeared before them one night. He told them that in the guise of their son, he will return and rescue them from Kansa's autocracy. The divine baby was born and the day he was born, Vasudeva found himself magically freed from prison. He ran away with the infant to a safer house and Lord Vishnu removed all the obstacles from Vasudeva's path.
Vasudeva reached a house in Gokul, exchanged Lord Krishna with a new born girl of Yashoda and Nanda and returned to the prison with the girl child. As soon as Kansa came to know about the new-born, he again tried to kill the child. The infant ascends to the heavens and transformed into the goddess Yogamaya and said,
"O foolish Kansa! What will you get by killing me? Your nemesis is already born.”