Dagestan in order to fully conquer the region, which was met with considerable success, although eventually he was forced to withdraw due to the extremity of the weather, the outbreak of disease and heavy raids by the various ethnic groups of Dagestan, forcing him to retreat with his army. From 1747 onwards, the Persian-ruled part of Dagestan was administered through the Derbent Khanate, with its center at Derbent. The Persian expedition of 1796 resulted in the Russian capture of Derbent in 1796. However, the Russians were again forced to retreat from the entire Caucasus following internal governmental problems, allowing Persia to capture the territory again. Russian rule consolidated It was not until the aftermath of the Russo-Persian War (1804–1813) that Russian power over Dagestan was confirmed, and that Qajar Persia officially ceded the territory to Russia. In 1813, following Russia's victory in the war, Persia was forced to cede southern Dagestan with its principal city of Derbent, alongside other vast territories in the Caucasus to Russia, conforming with the Treaty of Gulistan. The 1828 Treaty of Turkmenchay indefinitely consolidated Russian control over Dagestan and removed Persia from the military equation. Uprisings against imperial Russia The Russian administration, however, disappointed and embittered the highlanders. The institution of heavy taxation, coupled with the expropriation of estates and the construction of fortresses (including Makhachkala), electrified highlanders into rising under the aegis of the Muslim Imamate of Dagestan, led by Ghazi Mohammed (1828–1832), Gamzat-bek (1832–1834) and Shamil (1834–1859). This Caucasian War raged until 1864. Dagestan and Chechnya profited from the Russo-Turkish War (1877–1878), rising together against the Russian Empire. Chechnya rose again at various times throughout the late 19th and 20th centuries. Soviet era On 21 December 1917, Ingushetia, Chechnya, Dagestan and the rest of the North Caucasus declared independence from Russia and formed a single state called the "United Mountain Dwellers of the North Caucasus" (also known as the Mountainous Republic of the Northern Caucasus). The capital of the new state was moved to Temir-Khan-Shura. The first prime minister of the state was Tapa Chermoyev, a prominent Chechen statesman. The second prime minister was an Ingush statesman Vassan-Girey Dzhabagiev, who in 1917 also became the author of the constitution of the land, and in 1920 was re-elected for a third term. After the Bolshevik Revolution, Ottoman armies occupied Azerbaijan and Dagestan and the region became part of the short-lived Mountainous Republic of the