Kansa or Kamsa was the emperor of Mathura. He was the son of King Ugrasena and Padmavati.
Kansa deceitfully removed his father Ugrasena from the thrown and declared himself as the king of Mathura. Later he married the two daughters of Jarasandha, King of Magadha. Jarasandha was the friend of his advisor Banasur. The two wives of Kansa were Asti and Prapti.
The Bhagavata Purana states that, Kansa was not the biological son of Ugrasena. The story says that once a devil was flying through the city of Mathura and he saw Padmavati who was the beautiful queen of King Ugrasena. The demon was enticed by the attractiveness of Padmavati. The demon disguises himself in the form of Ugrasena. He seduced Padmavati and united with her which result the birth of Kansa. This fact was unknown to Kansa.
A divine prophesy said that Kansa would be killed by the eighth son of Devaki, his sister. The eighth son born to Devaki will be Lord Krishna. By then Devaki married Vasudeva, Kansa`s friend. Immediately after their marriage Kansa imprisoned both Devaki and Vasudeva. They were allowed to live only under the condition that all their children would be handed over to him as soon as they were born. The first six babies born to Devaki and Vasudeva were killed ruthless by Kansa.
The seventh child born to Devaki and Vasudeva was Balarama, who was saved from Kansa by magically transferring him to the womb of Rohini, another wife of Vasudeva. When the eighth son of Devaki and Vasudeva, Lord Krishna was born he was saved from Kansa and raised by a cowherd couple, Nanda and Yashoda. Kansa or Kamsa was eventually killed by Lord Krishna.
Kansa attempted to destroy Krishna as soon as he was born but failed. After that he decided to kill all the worshippers of Vishnu, young and old. He commanded his warriors to search for all young children throughout the country, and to slay every male child. Kansa afterwards employed demons to find and kill Krishna, and sent Akrura to bring him to Mathura. There was a severe contest in which Krishna slew the powerful demon Chanura, and afterwards killed king Kansa himself.