The Treaty of Hamedan was a treaty between the Ottoman Empire and the Hotaki dynasty signed in October 1727 in Hamedan, ending the Ottoman–Hotaki War (1722–27).
During the decline of the Safavid state, the Ottoman Empire (the Safavids' archrival) and the Russian Empire had taken advantage of Iran’s decadence to annex a large number of frontier districts. Posing as the legitimate heir to the Iranian throne, Ashraf Hotaki demanded restitution of all the annexed territories, which led the Ottoman Empire to declare war.
Ashraf Hotaki, after strengthening Isfahan’s fortifications, marched out to meet Turkish troops, which he defeated at Khorammabad, south of Hamadan, on 20 November 1726. The Afghan victory over a greatly superior military opponent was largely due to infiltration of the Ottoman ranks by agents provocateurs who emphasized the common Sunni faith of the Turks and the Afghans, deplored the fratricidal war between them, and advocated alliance against their common enemies, the heretical Persians; this adroit tactic sapped the morale of the Turkish troops and in addition procured the defection of the Kurdish cavalry.
The Afghans, having insufficient knowledge about diplomacy or ruling a nation, preferred not to push onward. Ashraf opened negotiations and offered terms favorable to the Ottoman Empire:
The great majority of Iranians still rejected the Afghan regime as usurpers. The Hotaki lived under great turmoil that made their hold on power tenuous and exhausted the strength of the Isfahan-based central government. That paved way for the rise of the Iranian military genius Nader Shah.