Jarasandha, the King of Magadha, was furious with Krishna for having killed Kansa, his son-in-law.
Jarasandha decided to teach Krishna and the Yadavas a lesson. Since the Yadavas were concentrated in and around Mathura, he decided to battle them and destroy the race forever.
Jarasandha then repeatedly attacked Mathura and each time, he caused massive death and destruction. The seventeen attacks that he led on Mathura had sapped the energy of the Yadavas and stunted the growth of the city and emptied the treasury.
Jarasandha was a powerful enemy with a huge army and the Yadavas barely managed to withstand his attacks with even the likes of Krishna and Balarama on their side.
One day, Krishna received disturbing news that Jarasandha had formed an alliance with several other kings to forever destroy the Yadava clan.
The alliance decided to simultaneously attack Mathura from several fronts. Jarasandha then sent a message to the Yadavas stating that they would be spared if they handed the heads of Krishna and Balarama to him.
DECISION OF KRISHNA
The Yadavas refused and readied themselves for war. Krishna then hit upon the idea of shifting the capital from Mathura to Dwaraka.
Krishna placed the suggestion before King Ugrasena, his grandfather.Ugrasena and all other courtiers and even the commanders of the Yadava army were against flight. Balarama too was against the move. He wanted to fight against Jarasandha.
Urgasena then pointed out to Krishna that if he ran away from the battlefield, he would forever be known as a Ranchor or one who has run away from a battlefield.
Krishna retorted that he had no worry about any new name being given to him. “I already have many names and one more does not make any difference”, he said. Moreover, I am willing to sacrifice my reputation for saving my people and their lives”, he said. “Why should people suffer because of me and Balarama”, he asked the gathering. He then suggested that the best solution would be to leave the city and go to a new place where it would be difficult for Jarasandha to attack them.
CREATION OF DWARIKA
When all the Yadavas unanimously give their consent, the capital was shifted to Dwaraka. When Jarasandha and his army reached Mathura, they were met with an empty city. An enraged Jarasandha put the city to destruction and called Krishna a coward-Ranchod-a man who had run away for battle.
Krishna though appeared unfazed by the new name. He knew that it would be better if one sacrificed his name and fame for the good of people.