The myth of Kamsa is told in a series of nested myths that are an excellent study of karma as a process over many lifetimes. But its primary location is within the Krishna myth cycle, where Kamsa plays a role in Krishna’s nativity and his first great battle with evil (though in previous lives Krishna had already fought battles with demons of all sorts before the one with Kamsa).
Kamsa’s karmic chain began at the beginning of a new cosmic creation. Kamsa was a rebirth of Kalanemi, a son of Virocana, an asura (demon) and the brother of Bali. After that rebirth as an evil human, his next rebirth was as Kaliya, a serpent king.
Kalanemi had had six sons, who were reborn from a curse by Brahma. The six sons had a karmic chain that brought them into contact with Krishna. They had been reborn as sons of Kalanemi because of what had happened in their previous lifetime. Brahma had created Marici, whose life remains clouded in some mystery. His greatness cannot be doubted, but some say that he was one of the Maruts (gods associated with Indra, thus gods of storms and battle). Others say that he was a Prajapati (progenitor, or grandfather), or even one of the seven maharishis, who were also the seven cosmic principles. According to the Bha- gavata Purana Marici (light) and Urna married (in the Brahmanda Purana his wife was Anasuya, “without spite”) and had six sons so powerful that they rivaled the creator. One day when they saw Brahma, they mocked him, saying that he was a father who had married his own daughter (Sarasvati). Brahma cursed them to be born as demons. And thus these six had rebirths in two important incarnations of Vishnu as sons of demons—first of Kalanemi and then of Hiranyakasiipu—and in one as humans, as sons of Vasudeva and Devaki.
As sons of Hiranyakasiipu the six brothers were pious and even received a boon from Brahma, that no one could kill them. But Hiranyakasipu cursed them to sleep in Patala (the underworld). After much pleading by his sons, he changed the curse so that they would be reborn as the first six sons of Devaki, so that their father in their previous life, Kalanemi, who was going to be reborn as Kamsa, would be their uncle in the next lifetime and could kill them. That would allow another rebirth, which was better than being stuck in Patala.
So the karmic chain of events brought Kalanemi and the six sons of Marici into a human rebirth. Kamsa was born as the son of Ugrasena, the king of Mathura. The meddling sage Narada told Kamsa that he was the result of a rape of his mother by a gandharva named Dramila, and that that was why his mother hated him and cursed him to be killed by a member of his own family. So Kamsa was not really surprised at the wedding of his sister Devaki when a voice from heaven said that his sister’s eighth son would kill him. Kamsa drew his sword and would have killed her, had not her husband Vasudeva pledged to give him each of the sons when they were born. So began intermittent imprisonments of the couple and the killing of their first six sons, who were being reborn to work out karma going all the way back to their sin of mocking the creator.
Kamsa personally bashed the brains out of each baby boy. Kamsa’s rule of Mathura became more and more evil. The seventh child was a girl and an incarnation of Mayadevi. Even though the seventh birth was not a boy, Kamsa tried to smash her head against the ground. But she rose into the air and announced that Kamsa’s death was near.
Sri Krishna was born as the eighth son of Devaki and Vasudeva. Kamsa tried many ways to kill Sri Krishna—all of which failed. Finally, he was slain by Krishna when an attempted ambush backfired. For the details about how Balarama and Krishna escaped death at the hands of Kamsa, see their entries as well as that of Devaki.