The declining country was repeatedly raided on its frontiers. Finally, Ghilzai Pashtun chieftain named Mir Wais Khan began a rebellion in Kandahar and defeated the Safavid army under the Iranian Georgian governor over the region, Gurgin Khan. In 1722, Peter the Great of neighbouring Imperial Russia launched the Russo-Persian War (1722–1723), capturing many of Iran's Caucasian territories, including Derbent, Shaki, Baku, but also Gilan, Mazandaran and Astrabad. At the mids of all chaos, in the same year of 1722, an Afghan army led by Mir Wais' son Mahmud marched across eastern Iran, besieged and took Isfahan. Mahmud proclaimed himself 'Shah' of Persia. Meanwhile, Persia's imperial rivals, the Ottomans and the Russians, took advantage of the chaos in the country to seize more territory for themselves. By these events, the Safavid dynasty had effectively ended. In 1724, conform the Treaty of Constantinople, the Ottomans and the Russians agreed to divide the newly conquered territories of Iran amongst themselves.