Shah Tahmasp II, the son of Shah Hussain ascended in 1134/1722 at Qazwin. He fled to Tabriz when Qazwin was shakened by the Afghans. The people of Qazwin repelled the Afghans. Mahmud however put to death many high officials and nobles, notably 3000 Kizilbash guards; cracking down the very backbone of the Safavid military. Thus suddenly was the whole fabric of the Safavid kingdom, bringing to an inglorious end. Mehmud was overthrown by his 26 years old cousin, called Ashraf in 1137/1725. At the time of his accession, Ashraf found himself in possession of Ispahan, Persian Irak, Fars, Kirman, Sistan, Qummis and western Khorasan. Shah Tahmasp II was the ruler of Qazwin and Mazandaran. In 1141/1729, Ashraf attacked the Safavids, but was defeated by Nadir Quli Beg, or Nadir Shah of Khorasan, the Safavid commander. He took possession of Ispahan and reinstated the Safavid monarchy by placing Shah Tahmasp II on the throne. Nadir then also drove away the Abdalis of Khorasan, and at last, he was made the chief commander of the Safavid military. These were the first outward signs that the tide had at last turned in Tahmasp favour, but a great deal had yet to be done.
In 1144/1732, just over two and a half years after Shah Tahmasp II had mounted the throne as a result of the restoration of the Safavid monarchy, he was forced by Nadir to abdicate in favour of his infant son Abbas III. Hence, Shah Tahmasp II spent the remainder of his unhappy and frustrated life in captivity. In 1148/1736, Shah Tahmasp II was joined by his son Shah Abbas III in prison when Nadir deposed him and captured the throne himself. Four years later, Shah Tahmasp II and his two sons Shah Abbas III and Ismail were put to death. Thus, Nadir Shah proclaimed the foundation of the Afsharid dynasty in 1148/1736.
Shah Ismail (1500-1524) had established the Safavid empire in Iran in 905/1500, which came to an end in 1148/1736 after a rule of about 236 years, from the time of Imam Abuzar Ali (d. 915/1509) to Imam Abul Hasan Ali (d. 1206/1792).
Imam Kassim Ali remained as a governor of Kirman for some times, and he came to Mahallat in 1204/1790. In Mahallat, he purchased many estates for his family, where he was very popular. In Mahallat, it is related that the Imam frequently arranged convivial parties at his residence. He used to invite the nobles and officials on every year during the celebrations of Eid-i Ghadir and Navroz. He died in Mahallat in 1143/1730 and was buried there. He had many sons, but the prominent among them were Abul Hasan Ali, the successor and Mirza Muhammad Bakir.
It must be noted that the first important move in the study of Ismailism had appeared in Europe in 1697, with the posthumous encyclopaedic work of a French scholar, Barthelemy d'Herbelot de Molainville (1625-1695). He was more accurately able to identify the Ismailis in Europe.