The Russo-Persian War of 1722–1723, known in Russian historiography as the Persian campaign of Peter the Great, was a war between the Russian Empire and Safavid Iran, triggered by the tsar's attempt to expand Russian influence in the Caspian and Caucasus regions and to prevent its rival, the Ottoman Empire, from territorial gains in the region at the expense of declining Safavid Iran. The Russian victory ratified for Safavid Iran's cession of their territories in the North Caucasus, South Caucasus and contemporary northern Iran to Russia, comprising the cities of Derbent (southern Dagestan) and Baku and their nearby surrounding lands, as well as the provinces of Gilan, Shirvan, Mazandaran and Astarabad conform the Treaty of Saint Petersburg (1723). The territories remained in Russian hands for nine and twelve years, when respectively according to the Treaty of Resht of 1732 and the Treaty of Ganja of 1735 during the reign of Anna Ioannovna, they were returned to Iran. Background Before the war, the nominal Russian border was the Terek River. South of that, the Khanates of Dagestan were nominal vassals of Iran. The ultimate cause of the war was Russia's desire to expand to the southeast and the temporary weakness of Iran. At the start of the war, the Iranian capital was under siege. The formal pretext was the grave damage inflicted to the many Russian merchants who inhabited the Safavid Iranian city of Shamakhi. In 1721, rebellious Lezgins, from within the declining Safavid Empire, had sacked and looted the city, killing many of its inhabitants including several Russian merchants. Artemy Volynsky, Russia's ambassador to Safavid Iran reported on the great damage done to the Russian merchants, to then incumbent Tsar Peter the Great (r. 1682–1725). The report stipulated that the 1721 event was a clear violation of the 1717 Russo-Iranian trade treaty, by which the latter guaranteed to ensure the protection of Russian nationals within the Safavid domains. With Safavid Iran in chaos, and the Safavid ruler in no possible way able to safeguard the provisions of the treaty, Volynsky urged Peter to take advantage of the situation, and to invade Iran, on the pretext of restoring order as an ally of the Safavid king. Indeed, Russia shortly after used the attack on its merchants in Shamakhi as the pretext to launch the war. Preparations Between 1714 and 1720, several Russian sailors had mapped the Caspian Sea. On 15 July