Diplomatic relations between Russia and Iran date back to 1521, when the Safavid Shah Ismail I sent an emissary to visit the Czar Vasili III. As the first diplomatic contacts between the two countries was being established, Shah Ismail was also working hard with the aim of joining forces against their mutual enemy, neighboring Ottoman Turkey. On several occasions, Iran offered Russia a deal exchanging 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.