In Shiraz, Lutf Ali Khan also sought no entry due to the hold of Aga Muhammad Khan. He fought next year with the Qajars, and defeated them in 1206/1792. In 1209/1794, Lutf Ali Khan captured Kirman. Aga Muhammad Khan besieged it for six months. It is said that Pir Mirza Muhammad Bakir had given a shelter to Lutf Ali Khan in a fort, who was seriously injured and sought mercy. Lutf Ali Khan finally managed to escape from Kirman, to which Aga Muhammad Khan, while entering Kirman, had accused the local people to have helped in escaping Lutf Ali Khan. By the vengeance he was wreaking on the inhabitants of Kirman, and issued orders to deprive all the adult males of their life, or of their eyesight; and the females and children, to the number of twenty thousand, were granted as slaves to the soldiers. G.R.G. Hambly writes in "Aqa Mohammad Khan and the establishment of the Qajar Dynasty" (JRAS, vol. L., January, 1963, p. 166) that, "Kerman was systematically ravaged for three months. Twenty thousand women and children were handed over to the army or sold as slaves. For the male population a different punishment was reserved and tradition relates that 7,000 eyes were brought to the conqueror, who personally counted them, informing the officer in charge of the operation: "Had one been missing, yours would have been taken!" As a memorial to the downfall of the Zand dynasty, a pyramid of skulls was erected in Bam on the spot where Lotf Ali Khan had been captured. Six hundred prisoners were executed in Kerman and their heads were carried to Bam by a further three hundred who were decapituted when they reached their destination. According to Henry Pottinger, this monument was still standing in 1810."
Lutf Ali Khan was arrested when he was about 25 years old. His eyes were torn from their sockets according to the tradition in Iranian kingdoms, and was executed in 1209/1794. With his death, the Zand dynasty had been declined in Iran, and Aga Muhammad Khan (1193-1212/1779-1797) founded the Qajarids empire.
In India, after the departure of Nadir, the Mughal empire in the time of Muhammad Shah (1719-1748) had absolutely become crippled. The constant expeditions of Ahmad Shah Abdali between 1161/1748 and 1181/1767 not only had broken down the backbone of the Mughal army, but also left the country economically collapsed. The next Mughal rulers on the throne of Delhi were Ahmed Shah (1748-1754) and Shah Alam II (1759-1806).
In upper Oxus, the Ismaili ruler in Shagnan, Mir Shah Amir Beg was a powerful ruler in Central Asia. He had left behind an inscription at Khorog, dating 1779 or 1780. His son Shah Wanji Khan had exiled the fire-worshippers from Shagnan, and extended his influence in Badakhshan and Chitral. His son Kubad Khan is reported to have violently harassed the local Ismailis followed by some disputes. He had been however driven out by his brother, Yousuf Ali Shah, the grandson of Kubad Khan, and became the next ruler in 1814. He also ruled the banks of Nahr Jaryab or Panj river.
In India, it may be noted that Multan had been a centre of the Shamsi Ismailis of Kashmir and Punjab, where the descendants of Pir Shams had served as the vakils of the Imam. In Sind and Kutchh, the descendant of Pir Dadu also worked as the vakils. While, the Kadiwal Sayeds were active in Kutchh and Sind, in which Sayed Ghulam Ali Shah, or Sayed Ghulmali Shah was most prominent. He initiated a bulk of the Hindus during the reign of Maharao Godmalji in Kutchh. Many other Indian dais and vakils are reported to have lived in the period under our review, whose names are known only through their ginans, viz., Sayed Fateh Ali Shah, Sayed Miran Mahdi, Sayed Miran Muhammad Shah, Sayed Ladha Shah, Sayed Kutabuddin, Sayed Aal-i Imam, Sayed Hussain etc.
During the time, a certain Mukhi Mehr Ali was an influential merchant in Sind. He visited Iran two times. It is said that he used to hospitalise the Indian pilgrims. He is also noted for renovating the shrine of Pir Shams in Multan in the time of Makhdum Jiwan Shah of Uchh in the year 1193/1779.
The Mughal emperor Aurengzeb (d. 1707) is reported to have persecuted the Ismailis in Gujrat and Sind, and most among them had taken refuge in Iran. Some among them returned afterwards, but many other settled in Kirman and died there, whose graves still exist, giving dates in Khojki character. The grave of Aga Nihal, possibly a Kashmiri Ismaili, bears the date of 1722 and Kamadia Muhammad dates 1725. One unknown grave indicates the date of 1742. In Mahallat, the graves of Khoja Peeru and Kamadia Bhalu of Sind bear the date of 1705 and 1711 respectively.
It seems that Abul Hasan Ali had moved to Shahr-i Babak in Kirman, most possibly in 1158/1745, situated about 180 kilometers southwest of the main city of Kirman. The decision seems to have been motivated for the security of the Indian pilgrims, since the Bakhtiyari tribesmen committed banditry on the roads, terrorizing the highways. Ahmad Ali Khan Viziri (d. 1295/1878) writes in "Tarikh-i Kirman" (Tehran, 1973, p. 542) that, "During the chaotic conditions of Iran after the downfall of the Safavids, the Indian Ismailis who regularly travelled to Anjudan and Mahallat regions for seeing their Imam and remitting to him their religious dues, were often plundered and killed between Nain and Yazd by the Bakhtiyari tribesmen."
The Imam thus, had to move to Shahr-i Babak, a location closer to the Iranian Gulf ports and the main pilgrimage route. He acquired extensive properties in Shahr-i Babak, also erected a winter residence in the city of Kirman, where his daughter, Fakhru'z-Zaman died in 1170/1756. He is also reported to have spent generously colossal money for the benefit of the people of Kirman, which enhanced his popularity. His fame in Kirman can be estimated from the fact that he was able to continue his governorship of Kirman when the Zand dynasty disintegrated upon Karim Khan's death in 1193/1779, and henceforth, the Imam ruled over Kirman independently.
Sayed Fateh Ali Shah (d. 1212/1798), an Indian vakil had visited Shahr-i Babak to see the Imam, and made its brief description in his one extant ginanthat: "The Lord resides in the western land as an Iranian. He speaks Persian in northern Iran (sheter deep). His residence is in Shahr-i Babak, and his name is Shah Abul Hasan Ali in elegant form."
Sind was noted for the great Sufi saint at that time, called Shah Abdul Latif Bhitai (1102-1165/1688-1751), who stood at the parting of the ways between the rule of the Mughals and that of the Kalhora dynasty. When emperor Aurengzeb died, Shah Abdul Latif was a youth of 18 years of age, and saw the rise of the early Kalhora to power. He was about 50 years old when Nadir Shah sacked Delhi and made Sind tributary to Iran. The collection of his Sufic poetry is called "Risalo". There are certain features of the poems of Shah Abdul Latif, which make it desirable to consider the possible influence of the ginans of Pir Sadruddin upon him. His ancestors in the fourth generation before him was the famous mystic, Sayed Abdul Karim, who is also known to have been influenced with the teachings of the Ismaili Pir. The sayings of Sayed Abdul Karim had a great impact on the mind of Shah Abdul Latif, who himself fed on the poetry of his great forbear and many verses of his poems are included in his poetry.
When Abul Hasan Ali had left for Shahr-i Babak in 1158/1745, he had been succeeded as a governor of Kirman by his cousin, Mirza Sadik. In 1206/1792, Aga Muhammad Khan seized Shiraz and sent his nephew, Fateh Ali to conquer Kirman. Fateh Ali occupied Kirman, and replaced Mirza Sadik, and himself became the governor of the provinces of Fars, Kirman and Yazd.
When Aga Muhammad Khan had massacred a large number of the local inhabitants in Kirman, the Ismailis were however spared in the operation. The Ismaili Sayed families and the relative of the Imam, living in Shahr-i Babak were allowed to repair to Kahek, where Aga Muhammad Khan gave them new pieces of land to compensate for what they had left behind in Kirman city; and assigned them according to the rank emoluments (wazifa) and pay (mostamarri).
Imam Abul Hasan Ali's first historical debut in the Iranian sources is recorded from the event of the seize of Kirman by Lutf Ali Khan in 1205/1791. His death is also recorded in the contemporary sources as 1206/1792 under the name of Sayed Abul Hasan Ali Shah Mahallati Kaheki. He had however passed his whole life in Shahr-i Babak, but his death took place in Mahallat on May 23, 1792, and was interred in Najaf.