Jarasandha, the king of Magadha, is a character of the epic Mahabharata. He was the son of Brihadratha, Vedic king.
Brihadratha was the king of Magadha. His wives were the twin princesses of Kashi. While he led a content life and was a famed king, he was unable to sire children. Frustrated over his inability, he retreated to the forest, eventually serving a rishi by the name of Chandakaushika. The rishi took pity upon him and on finding the cause of his sorrow, gave him a fruit that he blessed with fertility, instructing him to give it to his wife (The sage did not know that he had two). Not wishing to displease either wife, Brihadratha cut the fruit in half and gave it to both. Shortly after, each wife brought forth half a child. The two lifeless halves were viewed with horror, and Brihadratha ordered they be cast outside his city. A witch / man-eating demoness (Rakshasi) named Jara picked them up and put them together to carry them off. On their coming in contact a boy was formed, who cried out aloud. Not having the heart to kill a living child, the demoness gave it up to the king, explaining what had happened. The father gave the boy the name Jarasandha after the witch, because he had been put together by Jara.
Chandakaushika arrived at the court, and seeing the child, prophesied to Brihadratha that his son would be specially gifted, and would be renowned as a devotee of Lord Shiva.
Jarasandha became a famed and powerful king, extending his empire far and wide. He prevailed over many kings, and was crowned emperor of Magadha. Even while Jarasandh's power continued to grow, he had concerns about his future, as he had no heirs. Therefore, upon the advise of his close friend, King Banasur, Jarasandh decided to get his two daughters, Asti and Prapti married to the Crown-Prince of Mathura, Kansa. Jarasandh also lent his army and his personal advise to Kans for creating a coup in Mathura.
Eventually, after Kansa was killed by Lord Krishna, Jarasandh developed intense hatred for him and was determined to defeat and kill him. Seeing the pitiful situations of his widowed daughters, Jarasandh vowed to attack Mathura and take over the Kingdom. However, his efforts failed in response to the recently enthroned King Ugrasena, his supporters Vasudeva, the chief military strategist Akroor and the power of Lord Krishna and Balarama.
Even though his efforts failed repeatedly, Jarasandh attacked Mathura for a total of 18 times; after his last attack, Krishna convinced King Ugrasena and his father, Crown-Prince Vasudeva to rescind the land and establish a new Kingdom at Dwaraka, due to strategic reasons.
Jarasandha had many kings in captivity, and when Krishna returned from Dwaranka, he, with Bhima and Arjuna, went to Jarasandha's capital for the purpose of slaying their enemy (as Jarasandha was perceived to be a king who would not consent to Yudhisthira becoming the Emperor by performing the Rajasuya yagna) and liberating the kings. They went in disguise of three Brahmins and told Jarasandha to choose one of them to fight with. Jarasandha chose Bheema. Jarasandha refused to release the kings, and accepted the alternative of a combat, in which he was killed by Bhima. The fight lasted long, for 27 days. Finally, on Krishna's suggestion (which was unlawful considering the laws prevalent in those days pertaining to single combat), Bhima tore apart Jarasandha in two pieces lengthwise and threw away the pieces in opposite directions.
After his death, all the imprisoned Kings were released and Lord Krishna installed his more virtuous son to succeed his throne, making him the ally of Indraprastha.