Mother Earth, unable to bear the burden of the sins committed by evil kings and rulers, appealed to Brahma, the Creator, for help. Brahma prayed to Supreme Lord Vishnu, who assured Brahma that Vishnu himself would soon be born on earth to annihilate tyrannical forces.
One such evil force was Kansa, the ruler of Mathura (a city in the northern India state of Uttar Pradesh). Kansa's people were utterly terrified of him. On the day that Kansa's sister Devaki was married off to Vasudeva, a voice from the sky was heard prophesying that Devaki's eighth son would be the destroyer of Kansa. The frightened Kansa immediately unsheathed his sword to kill his sister, but Vasudeva intervened. Vasudeva implored Kansa to spare his beloved Devaki, and promised to hand over every one of their newborn children to him. Kansa relented but imprisoned both Devaki and her husband, Vasudeva.
When Devaki gave birth to her first child, Kansa came to the prison cell and slaughtered the newborn. In the same way, he killed Devaki's next six children. Even before her eighth child was born, Devaki and Vasudeva started lamenting its fate and theirs. Suddenly, Lord Vishnu appeared before them and said that he himself would be born to them and would rescue them and the people of Mathura. Vishnu asked Vasudeva to carry him right after his birth to the house of Vasudeva's friend, the chief cowherd Nanda in Gokula. There, Nanda's wife Yashoda had given birth to a daughter. Vasudeva was to exchange his boy and bring Yashoda's baby daughter back to the prison. Vishnu assured them, "Nothing shall bar your path."
At midnight, the divine baby was born in Kansa's prison. Following Lord Vishnu's instructions, Vasudeva clasped the child to his bosom and started for Gokula, but he found that his legs were in chains. He jerked his legs and was unfettered! The massive, iron-barred doors unlocked and opened by themselves.
While crossing the River Yamuna, Vasudeva held the baby high over his head. The rain fell in torrents, and the river was flooded. But the water parted for Vasudeva, and miraculously a five-mouthed snake followed him from behind and provided shelter over the baby.
When Vasudeva reached Gokula, he found the door of Nanda's house open. He exchanged the babies and hurried back to Kansa's prison with the baby girl. As Vasudeva entered, the doors of the prison closed and barred themselves behind him.
When Kansa heard about the birth of the baby girl, he rushed inside the prison and tried to kill the infant. But this time the baby slipped from his hands and flew into the air, reaching toward the sky. The baby was transformed into the goddess Yogamaya, who spoke to Kansa: "O foolish one! The one who was born to kill you still lives and is elsewhere!" Then she disappeared.
Krishna grew to be a very mischievous child, who constantly annoyed his adoptive mother, Devaki, and his nanny with jokes and miraculous tricks. Demons frequently tried to kill him and his adoptive family, but even as a baby he vanquished them all.
As a young adult, Krishna killed the tyrannical ruler Kansa, along with all his cruel associates. Krishna then at long last liberated his parents from prison and reinstated Ugrasen, the true King of Mathura.