The Ottoman–Hotaki War of 1726–1727 was a conflict fought between the Ottoman Empire and the Hotak dynasty, over control of all western and northwestern parts of Iran.
The Afghan Hotaks had overthrown the Safavid dynasty from power in Persia, and began centralizing rule in Iran after the battle of Gulnabad and siege of Isfahan.
The Hotaki dynasty was founded in 1709 by the Ghilzais of Kandahar who led a successful revolution against their Safavid suzerains.
The Safavids, once the arch enemy and most powerful opponent of the Ottomans, had been severely declining since the late 17th century due to incompetent rulers and civil strife.
During the Afghan invasion, the Russians under Peter I immediately launched a campaign against Iran, capturing and securing parts of Dagestan, Azerbaijan, and Gilan and having a claim on Astarabad due to the treaty of St. Petersburg.
In 1723 Ibrahim Pasha captured the city of Tiflis, although guerilla resistance in the province continued for quite some time.
[6] In the late spring of 1724, Ahmed Pasha marched towards the city of Erevan, and eventually capturing it on September 28, 1724.
[15][13][16] Following these engagements, the Ottomans suffered a loss of morale, with rumors rising on how they were defeated, ranging from them being attacked by snakes with wings, to the sky pouring down flames upon the army, as well as claims that the Afghan Amir was using magic.
[18][13] Preferring to not push onward due to internal issues and the state of the Afghan army, Ashraf Hotak began negotiating a peace agreement.
The Afghans withdrew from territories gained following their victories, with the Ottomans assuming control of Zanjan, Soltaniyeh, and Abhar.
[13][19] The war allowed Ashraf Hotak to unite and gain support from his Kurdish and Zoroastrian populations, and even Shia Shahsevan tribes.