In 1786, while Agha Mohammad Khan was in northern Iran, Jafar Khan quickly marched towards Isfahan and re-captured it. He then sent troops towards Kashan and Qum, while he marched towards Hamadan. He was, however, defeated by local tribal chieftains, such as a certain Khosrow Khan and Mohammad Hosayn Khan Qaragozlu. Jafar Khan then withdrew to Isfahan. When Agha Mohammad Khan heard about the Zand invasion of Isfahan and its surroundings, he quickly marched towards the city, which made Jafar Khan retreat back to Shiraz once again. In 1788, Agha Mohammad advanced closely to Shiraz, where he hoped to bait Jafar Khan out of Shiraz, which was strongly fortified, making it very hard to besiege. Unfortunately for Agha Mohammad Khan, Jafar Khan stayed in the city, which made Agha Mohammad Khan return to Isfahan, where appointed his brother Ali Qoli as its new governor, thus succeeding Jafar Qoli Khan. He then left for Tehran.