The Aga Khan sent his brother Muhammad Bakir to Sirjan to acquire provisions, and himself retreated to Rumni, a village near Shahr-i Babak. After four days, a message arrived from Muhammad Bakir Khan that he had been encircled in the fortress of Zaydabad at Sirjan by a large Qajarid force under the command of the beglerbegi of Kirman, Fazal Ali Khan Qarabaghi. The Aga Khan set out at once and succeeded to relieve his brother.
In 1257/1841, the Aga Khan defeated the royal forces of 4000 at the command of Isfandiyar Khan, the brother of Fazal Ali Khan near Dashtab. In the interim, Fazal Ali Khan had collected a force of 24000 to compel the Aga Khan to flee from Bam to Rigan on the border of Baluchistan and followed the Aga Khan close upon his heels like a shadow, and blockaded the way to the Bunder Abbas. The Aga Khan found himself between the horns of a dilemma on that juncture and finally decided to move to southern Khorasan to Afghanistan. Starting at Rawar, he transversed the arid Dasht-i Lut to Qain. In June, 1841 Muhammad Shah sent Abdullah Khan, the commander of his artillery from Tehran with orders to burn and demolish the towns and villages that were suspected of assisting the Aga Khan. He also sent Khan Ali Khan, the governor of Lar against the campaign. In the meantime, Habibullah Khan, the governor of Yazd also came out to fight with the Aga Khan, with eight guns and a body of troops. Thus, the Aga Khan had been embosomed on all sides by his enemies. In a battle with Khan Ali Khan, he was repulsed, and had to fly to the mountains of Baluchistan. During the night, however, the Aga Khan returned the mountain with reinforcements and surprised the troops of Khan Ali Khan in ambushing upon them at full gallop and turned them back.
Accompanied by his brothers and many soldiers and servants, the Aga Khan proceeded eastward, and after having adventured on a long perilous journey through central Iran, he crossed the borders, and arrived at Lash in Afghanistan in 1257/1841, marking an end of the longer Iranian period of Ismaili Imamate. In sum, after facing heavy odds and finding himself out-numbered, the Aga Khan I forced his way through the king's army and reached Afghanistan. Naoroji M. Dumasia writes in "The Aga Khan and his Ancestors" (Bombay, 1939, pp. 27-28) that, "His exile from Persia was a loss to that country, but Persia's loss was the gain of the British Empire, and his comradeship in arms with the British army cemented the ties of friendship.....The part which the Aga Khan played as an ally of the British in that disastrous war was in every way worthy of the heroic deeds of the great martyrs of Islam whose blood flowed in his veins."