History of Dagestan

Historically, Dagestan consisted of a federation of mountainous principalities in the eastern part of the North Caucasus. 
Located at the crossroads of world civilizations of north and south, Dagestan was the scene of clashes of interests of many states and until the early 19th century most notably that of between Persia (Iran) and Imperial Russia.
The name "Dagestan" historically refers to the eastern Caucasus, taken by the Russian Empire in 1860 and renamed the Dagestan Oblast. 
The current, more autonomous Republic of Dagestan covers a much larger territory, established in 1921 as the Dagestan Autonomous Soviet Socialist Republic, by inclusion of the eastern part of Terek Oblast.
Sassanid Persian rule and Khazar invasions of 6th CE.
In the 6th century the Sassanid Empire after more than 100 years of war conquered the Eastern Caucasus, resulting in the entire region of Dagestan falling under the influence of Persia.
In 552, "Khazars" invaded North-Eastern Caucasus and occupied northern lowlands of Dagestan. Reigning Shah of Persia Khosrau I (531—579), to protect his possessions from the new wave of nomads, began the construction of defensive fortifications in Derbent, that closed a narrow passage between the Caspian Sea and Caucasian mountains. Khosrau I owned fortress Gumik. The modern name "Derbent" is a Persian word (دربند Darband) meaning "gateway", which came into use in this same era, in the end of the 5th or the beginning of the 6th century CE, when the city was re-established by Kavadh I of the Sassanid dynasty of Persia.
As mentioned by the "Encyclopedia Iranica", ancient Iranian language elements were absorbed into the everyday speech of the population of Dagestan and the city of Derbent especially during the Sassanian era, and many remain current. In fact, a deliberate policy of “Persianizing” Derbent and the eastern Caucasus in general can be traced over many centuries, from Khosrow I to the Safavid shahs Ismail I, and ʿAbbās the Great. According to the account in the later "Darband-nāma", after construction of the fortifications Khosrow I “moved much folk here from Persia”, relocating about 3,000 families from the interior of Persia in the city of Derbent and neighboring villages. This account seems to be corroborated by the Spanish Arab Ḥamīd Moḥammad Ḡarnāṭī, who reported in 1130 that Derbent was populated by many ethnic groups, including a large Persian-speaking population.
Arab invasions of 7th-8th CE.
Dagestan passed from Iranian to Arab rule following the Muslim conquest of Persia. This period is known by a 150 years of war that peoples of north-eastern Caucasus fought between Arabs and Khazars. In 643, during the reign of caliph Umar ibn Khattab, Arab armies led by Abd al-Rahman ibn Rabi captured Derbent and the neighboring territories. In 652 Abd al-Rahman ibn Rabi was killed during the siege of Khazar city of Balanjar. In 662 the Khazars invaded Dagestan. In 698 Muhammad ibn Marwan, brother of caliph Abd al-Malik ibn Marwan, captured Derbent. In 705 Maslamah ibn Abd al-Malik, brother of caliph Al-Walid I, once again took over Derbent.
In 722, caliph Yazid II sent warlord al-Djarrah al-Hakami to defend the fortress of Derbent. Historian Al-Tabari writes about the campaigns of al-Djarrah: "Arabs defeating Khazars in southern Dagestan moved to the mountains of Dagestan, overcame the resistance of the people of Khamzin and Gumik and in punitive expeditions plunged and ransacked Kaitag and Tabasaran, for refusal to subordinate to their authority". Historian Balami writes that in 723 the warlord al-Djarrah "called one of his close commanders, gave him three thousand warriors and said to him: go to Kaitag, destroy there everything that you will meet on your way, fight everyone who will show you resistance and come back to me before the sunrise". In 723, Arab forces under the command of al-Djarrah move through the territory of Dagestan and capture Balanjar. In 730 al-Djarrah was killed in the battle of Marj Ardabil.
In 730–731, mentioned Maslamah ibn Abd al-Malik, brother of caliph Hisham ibn Abd al-Malik as well, "fortified Derbent in the best possible way" by building seven iron gates "and marched with his army to Kumukh". In 732 Marwan Ibn Muhammad, cousin of caliph Hisham, overcoming powerful fortresses obliges the rulers of mountainous Dagestan to pay tribute. Ibn Hayyat, Iranian author of the 9th century, informs that after the capture of "Gumik" and "Khunzakh", Marwan "went away from there, and entered the land of Tumen". According to Al-Balazuri, Marwan at the head of 120,000 army invaded Khazar possessions. The Khazar army endures a series of defeats. Marwan captures the city of Samandar. In 797 Khazars carried out an invasion of Dagestan.
Persian domination and eventual Russian conquest.
In the early 16th century the Persians (under the Safavids) reconsolidated their rule over the region, which would, intermittently, last till the early 19th century. In the 16th and 17th centuries, legal traditions were codified and mountainous communities ("djamaats") obtained a considerable degree of autonomy, while the Kumyk potentates ("shamhals") asked for the Tsar's protection following the Russo-Persian War (1651–53), despite a Russian loss. The Russians intensified their hold in the region in the 18th century, when Peter the Great took maritime Dagestan in the course of the Russo-Persian War (1722–23). Although the territories were returned to Persia in 1735 per the Treaty of Ganja.
The 18th century also saw the resurgence of the Khanate of Avaristan, which even managed to repulse the attacks of Nadir Shah of Persia at a certain point during his Dagestan campaign, and impose tribute on Shirvan and Georgia. From 1747 and on, the Iranian ruled part of Dagestan became administered through the Derbent Khanate, with its centre 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, making Iran recapture the territory again.
In 1806 the khanate was taken into the hold of the Russians but it was not until the aftermath of the Russo-Persian War (1804-1813) that Russian power over Dagestan was confirmed, and that Persia officially ceded the territory to Russia. In 1813, following Russia's victory in the war, Qajar Iran was forced to cede southern Dagestan with its principal city of Derbent, alongside other vast territories in the Caucasus to Russia, conform the Treaty of Gulistan. The 1828 Treaty of Turkmenchay indefinitely consolidated Russian control over Dagestan and removed Iran from the military equation.
Modern history.
Imperial Russian administration 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–32), Gamzat-bek (1832–34) and Shamil (1834–59). This Caucasian War raged until 1864, when Shamil was captured and the Khanate of Avaristan was abolished.
Dagestan and Chechnya profited from the Russo-Turkish War (1877–78), to rise together against Imperial Russia for the last time (Chechnya rose again various times throughout the late 19th and 20th centuries). 21 December 1917 Ingushetia, Chechnya, and Dagestan declared independence from Russia and formed a single state "United Mountain Dwellers of the North Caucasus" (also known as Mountainous Republic of the Northern Caucasus) which was recognized by major world powers. The capital of the new state was moved to Temir-Khan-Shura (Dagestan) 
The first prime minister of the state was elected Tapa Chermoyev a Chechen prominent statesman, second prime minister was elected an Ingush statesman Vassan-Girey Dzhabagiev who also was the author of the Constitution of the land in 1917, in 1920 he was reelected for the 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 Northern Caucasus. After more than three years of fighting the White movement and local nationalists, the Bolsheviks achieved victory and the Dagestan Autonomous Soviet Socialist Republic was proclaimed on January 20, 1921. Nevertheless, Joseph Stalin's industrialization largely bypassed Dagestan and the economy stagnated, making the republic the poorest region in Russia.
In 1999, an Islamist group from Chechnya, led by Shamil Basayev and Ibn Al-Khattab, launched a military invasion of Dagestan, with the aim of creating an "independent Islamic State of Dagestan".
The invaders were driven back to Chechnya by the Russian military. As a retaliation, Russian forces reinvaded Chechnya later that year.
Violence in the Republic exploded from the beginning of 2010 to the end of 2012. This upsurge led many people to claim that Dagestan was about to enter into a situation of sectarian civil war. Dagestan became the epicenter of violence in the North Caucasus with Makhachkala, Kaspiisk, Derbent, Khasavyurt, Kizlyar, Sergokala, Untsukul, and Tsumada all becoming hotbeds of militant activities.