(Austria, Poland, Venice) in 1686. During the war, the Russian army organized the Crimean campaigns of 1687 and 1689 and the Azov campaigns (1695–96). In the light of Russia's preparations for the war with Sweden and other countries' signing the Treaty of Karlowitz with Turkey in 1699, the Russian government signed the Treaty of Constantinople with the Ottoman Empire in 1700. Following the results of peace, Russia managed to annex Azov and get access to the Sea of Azov. After the Russians had defeated the Swedes and the pro-Swedish Empire Ukrainian Cossacks led by Ivan Mazepa in the Battle of Poltava in 1709, Charles XII of Sweden managed to persuade the Ottoman Sultan Ahmed III to declare war on Russia on November 20, 1710. The Prut campaign of Peter the Great ended very unsuccessfully for Russia. The Russian army, led by the tsar, was surrounded by a superior Turkish-Tatar army and was forced to agree to unfavorable peace conditions, according to which it returned the previously captured Azov to the Ottoman Empire. By the late 17th century, the Iranian Safavid dynasty, which neighbored both empires and had been one of the greatest rivals for Turkey for centuries (16th–19th centuries), had been heavily declining. Taking advantage of the situation, Russia and the Ottoman Empire conquered swaths of its territory comprising contemporary Dagestan, Azerbaijan, and Northern Iran, which was taken by Peter I in the Russo-Persian War (1722–1723); the Ottomans took the territory to the west, comprising modern day Armenia, parts of Eastern Anatolia, as well as western Iran. The gains by both were confirmed in the Treaty of Constantinople (1724). For a few years, they bordered each other along a large territory in the Caucasus, which caused further frictions. Russia managed to secure a favourable international situation by signing treaties with Persia in 1732 and 1735. These returned all Iranian territories gained since 1722 in the North and South Caucasus and Northern Iran, and avoided war with the emerging leader of Persia, Nader Shah. The treaties had other diplomatically favourable aspects as they established a Russo-Iranian alliance against Turkey, as Persia was at war with the Ottoman Empire. In the meantime Russia was also supporting the accession to the Polish throne of Augustus III in the War of the Polish Succession (1733–35), over the French-nominated Stanisław Leszczyński. Austria had been Russia's ally since 1726. Russia entered into another war with the