A courtier in Isfahan by the name of Malek Mahmoud Sistani reached an accord with the Hotaki Afghan conquerors in which he would set up an independent kingdom in khorasan in exchange for his recognition of Mahmud as Shah of Persia.
After the conclusion of the Siege of Isfahan, Mamud sent a contingent of his Afghans to subdue Qazvin where a new Safavid pretender Tahmasp had risen and proclaimed himself Shah.
He was forced to flee Qazvin but could not stay in the region permanently as those areas not under Afghan control were unremittingly coming under the marching boots of Ottoman soldiers invading from the west.
The Qajar contingent however remained with the Loyalist army despite Fathali's beheading and ironically it was a betrayal on the other side of the conflict that brought the siege to an end where Pir Mohammad allowed Nader to infiltrate the city walls forcing Sistani to take refuge in the citadel, surrendering shortly after.
The defeated Malek Mahmoud Sistani was surprisingly treated with courtesy and in a show of reconciliatory mercy allowed to spend the rest of his life as a sage (Though he was executed the following year when he became suspect in Nader's eyes).