Starting from the end of the 18th century, Shaki khans sought military assistance from the Russian Empire due to growing tensions with Qajars. As Agha Muhammad Khan re-established Iranian suzerainty over all former Safavid and Afsharid dependencies in the Caucasus around the time of his re-conquest of Georgia, so was the territory of the khanate added as well. In 1805, Mustafa Salim Khan signed a treaty with Alexander I of Russia effectively making Shaki Khanate Russian vassal state which was later only affirmed by the Russo-Persian Treaty of Gulistan in 1813. In 1819, Shaki Khanate was officially abolished and transformed into a Russian province subordinate to the Russian military administration. In 1840, it was renamed to Shaki Uyezd of Caspian Oblast. In 1846, the province was incorporated into Shemakha Governorate, in 1859 into Baku and in 1868 into Elisabethpol Governorate. After the establishment of Azerbaijan Democratic Republic in May 1918, Shaki was part of Ganja province and with the establishment of Soviet rule in Azerbaijan, Shaki was incorporated into Azerbaijan SSR on May 5, 1920.