Shah Sultan Hussein, the last of the Safavids, had been defeated outside Isfahan by a small band of Afghani tribesmen. Their leader, Mahmoud (1722-1725), at first showed a degree of clemency but seems to have become progressively more suspicious eventually murdering every one who had any association with the previous dynasty. He adopted the small palace behind Ali Qapu, which is shown above, as his headquarters. Today this is known after him as the Talar of Ashraf and is used by the army as an Officers' club. After an eight month seige he took Shiraz in 1724, but was unable to take Yazd, or to stop the Russians taking over large parts of the north of the country. In a fit of penance he immured himself in a dark vault for fourteen days, but on his return to daylight, he seems to have completely lost his reason and was eventually suffocated on the orders of his mother, in April 1725.
He was followed by his cousin Ashraf (1722-1729). Ashraf's reign was complicated by the aspirations of Tahmasb II, the last surviving member of the Safavid dynasty who had escaped from Isfahan. Tahmasb's armies, led by Nader Shah, defeated the Afhganis in a battle about 70km to the north of Isfahan, following which Ashraf returned to the city, leaving 4,000 Afhghanis dead on the field, and executed Shah Suleiman, who was living in retirement in the city. Ashraf then fled the city taking with him as much treasure as he could manage and all the ladies of the harem, and withdrew to Shiraz.
There is a touching story concerning Tahmasb II's return to Isfahan. On seeing him enter the city an old woman threw her arms around him and burst into tears. It emerged that she was his mother who, since the occupation of the city by Mahmoud, had disguised herself as a slave to escape being taken to Shiraz as a hostage
The Afghanis were pursued and routed near Persepolis. Ashraf escaped into the desert but was eventually assasinated by a Baluchi in 1729, and his head was sent to Shah Tahmasb II.
Ashraf's rule over Isfahan is largely unmarked architecturally. There is an inscription in the Porch of Omar in the Masjed-e-Jomeh, and the remains of the palace of Farahabad south west of the city on the road to Dastgerd, (now a military complex and closed to the public), which he burnt.