Shirvan (from Persian: شروان, romanized: Shirvān; Azerbaijani: Şirvan; Tat: Şirvan), also spelled as Sharvān, Shirwan, Shervan, Sherwan and Šervān, is a historical region in the eastern Caucasus, known by this name in both Islamic and modern times. Today, the region is an industrially and agriculturally developed part of the Azerbaijan Republic that stretches between the western shores of the Caspian Sea and the Kura River, centered on the Shirvan Plain.
However, Said Nafisi points out that according to Khaqani's poems, where Khaqani contrasts his home town with kheyrvān (Persian: خیروان), the original and correct pronunciation of the name was Sharvān. So all etymologies relating this name to sher/shir (lion in Persian and Kurdish) or Anushiravan are most probably folk etymology and not based on historical facts. The form Shervān or Shirvān are from later centuries. According to the Encyclopedia of Islam, Shirwan proper comprised the easternmost spurs of the Caucasus range and the lands which sloped down from these mountains to the banks of the Kur river. But its rulers strove continuously to control also the western shores of the Caspian Sea from Ḳuba (the modern town of Quba) in the district of Maskat in the north, to Baku in the south. To the north of all these lands lay Bab al-Abwab or Derbend, and to the west, beyond the modern Goychay, the region of Shaki. In mediaeval Islamic times, and apparently in pre-Islamic Sāsānid ones also, Shirwan included the district of Layzan, which probably corresponds to modern Lahidj, often ruled as a separate fief by a collateral branch of the Yazidi Shirwan Shahs.
The 19th century native historian and writer Abbasgulu Bakikhanov defines it as: "The country of Shirvan to the east borders on the Caspian Sea, and to the south on the river Kur, which separates it from the provinces of Moghan and Armenia".
Shirvanshah also spelled as Shīrwān Shāh or Sharwān Shāh, was the title in medieval Islamic times of a Persianized dynasty of Arabic origin. They ruled the area independently or as a vassal of larger empires from 800 A.D. up to 1607 A.D. when Safavid rule became firmly established.
When the Shirvanshah Shah dynasty was ended by the Safavid Shah Tahmasp I, Shirwan formed a province of the Safavids and was usually governed by a Khan, who is often called Beylerbey. Shirvan was taken by the Ottomans in 1578; however, Safavid rule was restored by 1607. In 1722, during the Russo-Persian War (1722-1723), the Khan of Quba, Husayn Ali, submitted to Peter the Great and was accepted as his dignitary. The Treaty of Saint Petersburg (1723) forced the Iranian king to recognise the Russian annexation. By the treaty between the Russian and Ottoman Empires in the year 1724, the coast of the territory of Baku, which was occupied by the Russians, was separated from the rest of Shirvan, which was left to the Ottomans. It was only when Nader Shah defeated the Ottomans (1735) that the Russians ceded back the coastal land and the other areas in the North and South Caucasus as conquered in 1722-1723 from Safavid Iran conform the Treaties of Resht and Ganja, and the area became part of the Afsharid Empire, by which century long Iranian rule was restored.
When the Qajars had succeeded in restoring the unity of Persia, the sons of the Khan were no more able to maintain their independence like the other Caucasian chiefs and had to choose between Russia and Persia. The Khan of Shirwan, Mustafa, who had already entered into negotiations with Zubov, submitted to the Russians in 1805, who occupied the Persian cities of Derbend and Baku the next year (1806) during the Russo-Persian War (1804-1813), but soon afterwards he made overtures to the Persians and sought help from them. By the Treaty of Gulistan (12/24 October 1813) following the end of the 1804-1813 war, Persia was forced to cede its territories and regions comprising Darband, Quba, Shirwan and Baku, while giving up all claims on them as well. Nevertheless, Mustafa continued to have secret dealings with Persia. It was not until 1820 that his territory was occupied by Russian troops; the Khan fled to Persia and Shemakha was irrevocably incorporated in Russian territory. Iranian anger while being dissatisfied with losing swaths of its integral territories in the North and South Caucasus subsequently sparked the Russo-Persian War (1826-1828), which resulted in another Iranian loss, as well as the ceding of its last remaining territories in the Caucasus comprising what is now Armenia, and southern parts of the contemporary Republic of Azerbaijan. The Treaty of Turkmenchay of 1828 officially ratified the forced ceding of these Iranian territories to Imperial Russia, while it would also mark the official end of millennia long intertwined Iranian hegemony, rule, and influence over the Caucasus region, including Shirvan.
The term Shirvani/Shirvanli is still in use in Azerbaijan to designate the people of Shirvan region, as it was historically. Since ancient time, the bulk population of Shirvan were Caucasian speaking groups. Later on Iranization of this native population and subsequent Turkification since the Seljuq era occurred. The bulk of the population today are Turkic-speaking Azerbaijanis, although there are also smaller Caucasian speaking and Iranian speaking minorities.
The original population were Paleo-Caucasians and spoke Caucasian languages, like the Caucasian Albanians. Today, other Daghestani Caucasian languages such as Udi, Lezgian and Avar are still spoken in the region.
Iranian penetration started since the Achaemenid era and continued in the Parthian era. However it was during the Sassanid era that the influence really increased and Persian colonies were set up in the region. According to Vladimir Minorsky: . Abu al-Hasan Ali ibn al-Husayn Al-Masudi (896–956), the Arab historian states Persian presence in Aran, Bayleqan, Darband, Shabaran, Masqat and Jorjan. From 9th century, the urban population of Shirwan increasingly moved to Persian language, while the rural population seems to mostly have retained their old Caucasian languages. Up to the nineteenth century, there was still a large number of Tat population (who claim to be descendants of Sassanid era Persian settlers), however due to similar culture and religion with Turkic-speaking Azerbaijanis, this population was partly assimilated.The presence of Iranian settlers in Transcaucasia, and especially in the proximity of the passes, must have played an important role in absorbing and pushing back the aboriginal inhabitants. Such names as Sharvan, Layzan, Baylaqan, etc., suggest that the Iranian immigration proceeded chiefly from Gilan and other regions on the southern coast of the Caspian
Turkic penetration in the region started in the Khazar era, however there are no unambiguous references to settlements. The Turkification of the region started in the Seljuq era, although the area in parallel maintained its Persian culture under the Persianized Shirvanshah until the Safavid era. From the Safavid era onwards, the Turkification of the region accelerated with new wave of Turkoman settlements.