a part of its territory (for example Derbent and Baku in 1586) for its support in its wars against their Ottoman archrivals. In 1552–53, Safavid Iran and the Muscovy state in Russia exchanged ambassadors for the first time, and, starting in 1586, they established a regular diplomatic relationship. In 1650, extensive contact between the two people, culminated in the Russo-Persian War (1651–53), after which Russia had to cede its footholds in the North Caucasus to the Safavids. In the 1660s the famous Russian Cossack ataman Stenka Razin raided, and occasionally wintered at, Persia's north coast, creating diplomatic problems for the Russian Czar in his dealings with the Persian Shah. The Russian song telling the tragic semi-legendary story of Razin's relationship with a Persian princess remains popular to this day. Peace reigned for many decades between the two peoples after these conflicts, in which trade and migration of peoples flourished. The decline of the Safavid and Ottoman state saw the rise of Imperial Russia on the other hand. After the fall of Shah Sultan Husayn brought the Safavid dynasty to an end in 1722, the greatest threats facing Persia were Russian and Ottoman ambitions for territorial expansion in the Caspian region—north-western Persia specifically. During the Safavid period, Russian and Persian power was relatively evenly balanced. Overall, the common anti-Ottoman struggle served as the main common political interest for Iran and Russia throughout the period of Safavid rule, with several attempts to conclude an anti-Ottoman military treaty. Following Shah Husayn's fall, the relationship lost its symmetry, but it was largely restored under Nader Shah. In his later years of rule, Peter the Great found himself in a strong enough position to increase Russian influence more southwards in the Caucasus, the Caspian Sea and the Black Sea, challenging both the Safavids and the Ottomans. He made the city of Astrakhan his base for his hostilities against Persia, created a shipyard, and attacked the weakened Safavids in the Russo-Persian War (1722–1723), capturing many of its territories in the Caucasus and northern mainland Iran for several years. After several years of political chaos in Persia following the fall of the Safavids, a new and powerful Persian empire was born under the highly successful military leader Nader Shah. Fearing a costly war which would most likely be lost against Nader and also being flanked by the Turks in the west, the Russians were forced to give