Azerbaijan, or Ancient Media within Persia, before the Treaty of Gulistan of 1813 and the Treaty of Turkmenchay of 1828
By the Treaty of Gulistan, concluded after the first Russo-Persian War of 1804–1813, Persia recognised the transfer to Russia of Dagestan, Eastern Georgia (that is, Kartli-Kakheti), Imereti, Mingrelia, Guria and Abkhazia, as well as the Karabakh, Ganja, Sheki, Shirvan, Quba, Baku, Derbent and Talysh khanates of Northern Azerbaijan.
By the Treaty of Turkmenchay, which followed the war of 1826–1828, the Erivan and Nakhichevan khanates passed to the Russian Empire, and the frontier with Persia was fixed along the River Araks. The treaty confirmed the partition of Azerbaijan into a northern part, within Russia, and a southern part, within Persia.