The Hotaki's were an Afghan tribe and dynasty that ruled very shortly over nowadays Afghanistan, most of Iran, and western Pakistan from 1722 to 1729, after having taken opportunity of the heavily declining and plagued by civil strife and royal intrigues Safavid Dynasty of Persia. The Safavids, once the arch enemy and most powerful opponent of the Ottomans, had been severely declining since the late 17th century. The Hotaki dynasty was founded in 1709 by GhilzaiPashtuns of Kandahar who led a successful revolution against their Safavid suzerains.
During decline of the Safavid state, the Ottoman empire (the Safavids arch rival), and Russian empires, had taken advantage of Iran’s decadence to annex de facto a large number of frontier districts. Posing as if he was the legitimate inheritor of the Iranian throne, Ashraf demanded restitution of all the annexed territories. The Ottomans took offense at this arrogance, as they saw it, and proceeded to sever relations and open hostilities in Azerbaijan in the spring of 1726. Since one of their declared war aims was to restore the Safavids as a client dynasty, Ashraf’s first response was to put Sultan Husayn, who was living in captivity at Isfahan, to death in the autumn of 1726. Then, after strengthening the city’s fortifications, he marched out to meet Turkish troops and defeated them 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 procured the defection of the Kurdish cavalry. Preferring not to push onward, Ashraf opened negotiations which led to the signature of a peace treaty in October, 1727 (Treaty of Hamedan). The Afghans, having completely no knowledge about diplomacy or ruling a nation, agreed with the treaty which confirmed Ottoman sovereignty over all the western and northwestern parts of Iran and, in return for Ashraf’s abandonment of his territorial claims, gave him official recognition as Shah of Persia with rights of minting coins and sending annual pilgrimage caravans to Mecca.
The great majority of Iranians still rejected the Afghan regime as usurping since the day they invaded. The dynasty lived under great turmoil due to bloody succession feuds and resultant waves of internal revolts 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 and subsequently the continued wars of the Persian Empire with their Ottoman arch rivals, of which Persia would win most of the subsequent ones to come.
Tucker, Spencer C., ed. (2009), "November 8, 1726", A Global Chronology of Conflict: From the Ancient World to the Modern Middle East: From the Ancient World to the Modern Middle East (illustrated ed.), ABC-CLIO, p. 727, ISBN9781851096725