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 back all territories and retreat from the entire Caucasus and northern mainland Iran as according to the Treaty of Resht (1732) and Treaty of Ganja (1735) during the reign of Anna of Russia. The terms of the treaty also included the first instance of close Russo-Iranian collaboration against a common enemy, in this case the Ottoman Turks.