Conflict between the Russian Empire and Safavid Iran
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 Iran guaranteed to ensure the protection of Russian nationals within the Safavid domains. With Safavid Iran in chaos, and the Safavid ruler completely unable 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 1722, Peter issued a manifesto in several local languages justifying the invasion, drawn up by Dimitrie Cantemir. Peter gathered 22,000 infantry, 9,000 dragoons and 70,000 Cossacks, Tatars and Kalmyks. For transport, he created the Caspian Flotilla at Astrakhan under Fyodor Apraksin. The infantry, artillery and stores were to be shipped by sea to the mouth of the Sulak River while the cavalry went overland from Tsaritsyn and Mozdok. By the time Peter was assembling his forces for the attack, the Safavid state had already entered the final stages of collapse.
Campaign.
"All dates old style used in Russian accounts of the time, followed by the new style (N.S.) modern equivalent, 11 days ahead of the Julian calendar."
Phase One (1722).
The flotilla arrived at the mouth of the Sulak on 27 July 1722 (August 7 N.S.) and Peter, carried ashore by four boatmen, was the first to disembark. There, he learned that some of his cavalry had been defeated by Kumyks and Chechens at Endirey. Peter responded with a punitive expedition using Kalmukh troops. He went south and camped at what later became Petrovsk. On August 12 (August 23 N.S.), he made a state entry into Tarki, the capital of the Shamkhalate of Tarki, where the ruler received him as a friend. Next day, he headed south to Derbent, the flotilla following coastwise. He sent envoys to the next major ruler, the Sultan of Utemish. Sultan Mahmoud Otemishsky killed the envoys and gathered about 16,000 men at Utemish to bar the way. The mountaineers fought valiantly, but could not withstand the disciplined infantry. Utemish was burned and all the prisoners hanged in revenge for the murder of the envoys. On learning of this, the Khan of Derbent offered Peter the keys to the city on August 23 (September 3 N.S.). Derbent is at a narrow point on the coastal plain and has long been considered the northern gateway to Iran. While in Derbent, Peter learned that the flotilla had been caught in a storm and most of the supplies lost. Since there was no possibility of resupply this late in the season, he left a strong garrison at Derbent, marched back to the Terek River, took ship to Astrakhan and, on December 13 (December 24 N.S.), made a triumphal entry into Moscow.
Vakhtang VI of Kartli (central Georgia) was a vassal of Iran and had been their captive for seven years. Given the weakness of Iran, he made an arrangement with Russia. In September 1722, he advanced on Ganja. When the Russians did not join him, he returned to Tbilisi in November. This provocation of Iran led to a disastrous invasion of his country.
Phase Two (1722/23).
Before leaving Astrakhan, Peter, on 6 November (17 November N.S.), sent Colonel Shipov and two battalions south to occupy the Iranian city of Rasht at the southwest corner of the Caspian. The locals wanted help against the invading Afghans but quickly changed their minds. 15,000 men were gathered, Shah Tamasp ordered the Russians out (February) and towards the end of March the Russians defeated the Iranians, and had decisively taken the Caspian Sea town.
After a long siege on 26 June 1723 (7 July 1723 N.S.) General Matyushkin took the Iranian town of Baku and soon Shirvan to the west and then the three Iranian provinces on the south coast of the Caspian Sea. On September 12 (September 23 N.S.), the Russians and Iranians made a treaty in which the Russians would drive out the Afghans and restore Shah Tahmasp to the throne in return for the cession of Derbent, Baku and the three south coast provinces. Next year, Prince Meshchersky went to Iran but was unable to secure ratification and was almost killed.
The war was formally concluded by the 1723 Treaty of Saint Petersburg, which recognized the Russian annexation of the west and south coasts of the Caspian. By the 1724 Treaty of Constantinople, Russia recognized Turkish control of nearly everything west of what they had captured, thereby partitioning Transcaucasia between the two powers. The Russians lost many soldiers to disease. At the same time, Nader Shah restored Iranian power. In 1732, through the Treaty of Resht, Russia withdrew to approximately the current Iranian border. In 1735, as a result of the Treaty of Ganja, Russia withdrew to its former border along the Terek River.
Aftermath.
The war was a costly war for both sides in different measures. Iran had lost swaths of its territories, while Russia had suffered large human losses. In total, the Russians lost 6,531 people during the campaign, and about 36,000 during the occupation of the Caucasus, mostly from diseases. Grave damage was inflicted by the Russians on the occupied areas. Thus, in Gilan, one of the consequences of the occupation was the rapid decline of sericulture, as many of those involved in it fled. It took years for the industry to revive.
Peter was determined to keep the newly conquered Iranian territories in the Caucasus and northern mainland Iran. However, he was concerned about their safety and thus ordered the fortifications at Derbent and Holy Cross to be strengthened. He was determined to attach Gilan and Mazandaran to Russia. In May 1724, the Tsar wrote to Matiushkin, Russian commander in Rasht, that he should invite "Armenians and other Christians, if there are such, to Gilan and Mazandaran and settle them, while Muslims should be very quietly, so that they would not know it, diminished in number as much as possible."
In 1732, on the eve of the Russo-Turkish War, the government of Empress Anna Ioannovna, Peter's successor, returned many of the annexed territories to Iran as a part of the Treaty of Resht, to construct an alliance with the Safavids against the Ottoman Empire. By the 1735 Treaty of Ganja, the remaining territories were returned, including Derbent, Baku and Tarki, and Iran was again in full possession of its territories in the North and South Caucasus and in contemporary northern Iran. The Russian troops nevertheless had not evacuated from the Iranian provinces until 1734.
As "The Cambridge History of Iran" adds, "perhaps the only long-term consequence was the consciousness on the part of Russia's rulers that their armies had once marched beyond the Caucasus, that the Russian flag had flown over the southern shore of the Caspian Sea."
However, the sequel was additionally disastrous for the Georgian rulers who had supported Peter's venture. In eastern Georgia, Vakhtang VI of Kartli lost his throne and sought protection of the Russian court in 1724. In western Georgia, Alexander V of Imereti had to accept an Ottoman suzerainty on more stringent terms. The Ottomans, further, alarmed by the Russian intervention, strengthened their hold along the Caucasian coastline.
References.
 ;templatestyles src="Reflist/styles.css" / ;