Jarāsandha, the King of Magadha, besieged the city of Mathurā not only once but seventeen times in the same way, equipped with the same number of military phalanxes. Each and every time, he was defeated and all his soldiers were killed by Kṛṣṇa, and each time he had to return home disappointed. Each time, the princely order of the Yadu dynasty arrested Jarāsandha in the same way and again released him in an insulting manner, and each time Jarāsandha shamelessly returned home.
While Jarāsandha was attempting his eighteenth attack, a Yavana king somewhere to the south of Mathurā became attracted by the opulence of the Yadu dynasty and also attacked the city. It is said that the King of the Yavanas, known as Kālayavana, was induced to attack by Nārada. This story is narrated in the Viṣṇu Purāṇa. Once, Garga Muni, the priest of the Yadu dynasty, was taunted by his brother-in-law. When the kings of the Yadu dynasty heard the taunt they laughed at him, and Garga Muni became angry at the Yadu kings. He decided that he would produce someone who would be very fearful to the Yadu dynasty, so he pleased Lord Śiva and received from him the benediction of a son. He begot this son, Kālayavana, in the wife of a Yavana king. This Kālayavana inquired from Nārada, “Who are the most powerful kings in the world?” Nārada informed him that the Yadus were the most powerful. Thus informed, Kālayavana attacked the city of Mathurā at the same time that Jarāsandha tried to attack it for the eighteenth time. Kālayavana was very eager to declare war on a king of the world who would be a suitable combatant for him, but he had not found any. However, being informed about Mathurā by Nārada, he thought it wise to attack this city with thirty million Yavana soldiers.
When Mathurā was thus besieged, Lord Śrī Kṛṣṇa began to consider, in consultation with Baladeva, how much the Yadu dynasty was in distress, being threatened by the attacks of two formidable enemies, Jarāsandha and Kālayavana. Time was growing short. Kālayavana was already besieging Mathurā from all sides, and it was expected that the day after next, Jarāsandha would also come, equipped with the same number of divisions of soldiers as in his previous seventeen attempts. Kṛṣṇa was certain that Jarāsandha would take advantage of the opportunity to capture Mathurā when it was also being besieged by Kālayavana. He therefore thought it wise to take precautionary measures for defending against an attack upon Mathurā from two strategic points. If both Kṛṣṇa and Balarāma were engaged in fighting with Kālayavana at one place, Jarāsandha might come at another to attack the whole Yadu family and take his revenge. Jarāsandha was very powerful, and having been defeated seventeen times, he might vengefully kill the members of the Yadu family or arrest them and take them to his kingdom. Kṛṣṇa therefore decided to construct a formidable fort where no two-legged animal, either man or demon, could enter. He decided to keep His relatives there so that He would then be free to fight the enemy. It appears that formerly Dvārakā was also part of the kingdom of Mathurā. In Śrīmad-Bhāgavatam it is stated that Kṛṣṇa constructed the fort in the midst of the sea. Remnants of the fort Kṛṣṇa constructed still exist in the Bay of Dvārakā.
Kṛṣṇa first of all constructed a very strong wall covering ninety-six square miles, and the wall itself was within the sea. It was certainly wonderful and was planned and constructed by Viśvakarmā. No ordinary architect could construct such a fort within the sea, but an architect like Viśvakarmā, who is considered to be the engineer among the demigods, can execute such wonderful craftsmanship anywhere in the universe. If huge planets can float in weightlessness in outer space by the arrangement of the Supreme Personality of Godhead, surely the architectural construction of a fort covering ninety-six square miles within the sea was not very wonderful.
It is stated in Śrīmad-Bhāgavatam that this new, well-constructed city, developed within the sea, had regular planned roads, streets and lanes. There were also well-planned parks and gardens filled with plants known as kalpa-vṛkṣas, or desire trees. These desire trees are not like the ordinary trees of the material world; the desire trees are found in the spiritual world. By Kṛṣṇa’s supreme will, everything is possible, so such desire trees were planted in Dvārakā, the city constructed by Kṛṣṇa. The city was also filled with many palaces and gopuras, or big gates. These gopuras are still found in some of the larger temples. They are very high and constructed with fine artistic skill. Such palaces and gates held golden waterpots (kalaśas). These waterpots on the gates or on the palaces are considered auspicious signs.