As per the Hindu epic Mahabharata, Jarasandha was the king of Magadha. He was a descendant of the king Brihadratha, the founder of the Barhadratha dynasty of Magadha. He was also a great devotee of the Hindu god Shiva. He was a great senapati and a Maharathi, but he is generally held in negative light owing to his enmity with the Yadava clan in the Mahabharata. Jarasandha raided Mathura 17 times and Krishna was defeated every time. Krishna and his brother Balarama ran away every time from Jarasandha so Krishna has been named as Ranchod, meaning deserter.
On the 17th occasion, Krishna and the Yadavas decided to leave Mathura forever and retreated. To avoid unnecessary loss of lives in future, Krishna moved his capital to Dwaraka. Since Dwaraka was an island city guarded heavily by Yadava Army, Jarasandha was not able to invade Dwaraka anymore. To attain the capacity to invade Dwaraka, Jarasandha planned to conduct a Yagna to please the god Shiva. For this Yagna, He had imprisoned 95 kings and was in need of 5 more kings, after which he was planning to perform the Yagna, sacrificing all the 100 kings.
Jarasandha thought that this Yagna will make him win the powerful Yadava Army. Krishna, on the other hand, made a plan for eliminating Jarasandha. The Pandava king Yudhishthira was planning to make a Rajasuya yagna in order to become the emperor. Krishna convinced his cousin Yudhishthira that Jarasandha was the only obstacle to oppose Yudhishthira from becoming an emperor. Krishna planned a clever scheme to eliminate Jarasandha by making Yudhishthira’s brother Bhima wrestle with the Jarasandha in a duel.
Like Karna, Jarasandha was also very good in giving charity donations. After performing his Shiva pooja, he used to give whatever the Brahmins asked for. On one such occasion Krishna, Yudhishthira’s brothers Arjuna and Bhima in the guise of Brahmins met Jarasandha. Krishna asked Jarasandha to choose any one of them for a wrestling match. Jarasandha chose Bhima, the strongman, to wrestle. Both of them fought for 14 days.
Bhima lost hope to win the battle and sought help of Krishna. Krishna, who then knew of the secret of Jarasandha’s weakness from the victory of Karna over Jarasandha took a twig and split it into two. Bhima understood the clue and split Jarasandha’s body into two, slaying the king. After his death, the Pandavas released all the 95 kings imprisoned by Jarasandha and crowned his son, Sahadeva as the king of Magadha. Thus, these 95 kings along with Sahadeva, the new ruler of Magadha became an ally of Pandavas who took part in the Mahabharata war later.