Azerbaijan
From the Sasanid period to the Safavid period

The Sasanian Empire turned Caucasian Albania into a vassal state in 252, while King Urnayr officially adopted Christianity as the state religion in the 4th century. Despite Sassanid rule, Caucasian Albania remained an entity in the region until the 9th century, while fully subordinate to Sassanid Iran, and retained its monarchy. Despite being one of the chief vassals of the Sasanian emperor, the Albanian king had only a semblance of authority, and the Sasanian marzban (military governor) held most civil, religious, and military authority.

In the first half of the 7th century, Caucasian Albania, as a vassal of the Sasanians, came under nominal Muslim rule due to the Muslim conquest of Persia. The Umayyad Caliphate repulsed both the Sasanians and Byzantines from the South Caucasus and turned Caucasian Albania into a vassal state after Christian resistance led by King Juansher was suppressed in 667. The power vacuum left by the decline of the Abbasid Caliphate was filled by numerous local dynasties such as the Sallarids, Sajids, and Shaddadids. At the beginning of the 11th century, the territory was gradually seized by the waves of migrating Oghuz Turks from Central Asia, who adopted a Turkoman ethnonym at the time. The first of these Turkic dynasties established was the Seljuk Empire, which entered the area now known as Azerbaijan by 1067.

The pre-Turkic population that lived on the territory of modern Azerbaijan spoke several Indo-European and Caucasian languages, among them Armenian and an Iranian language, Old Azeri, which was gradually replaced by a Turkic language, the early precursor of the Azerbaijani language of today. Some linguists have also stated that the Tati dialects of Iranian Azerbaijan and the Republic of Azerbaijan, like those spoken by the Tats, are descended from Old Azeri. Locally, the possessions of the subsequent Seljuk Empire were ruled by Eldiguzids, technically vassals of the Seljuk sultans, but sometimes de facto rulers themselves. Under the Seljuks, local poets such as Nizami Ganjavi and Khaqani gave rise to a blossoming of Persian literature on the territory of present-day Azerbaijan.

Shirvanshahs, the local dynasty of Arabic origin that was later Persianized, became a vassal state of Timurid Empire of Timur and assisted him in his war with the ruler of the Golden Horde Tokhtamysh. Following Timur's death, two independent and rival Turkoman states emerged: Qara Qoyunlu and Aq Qoyunlu. The Shirvanshahs returned, maintaining for numerous centuries to come a high degree of autonomy as local rulers and vassals as they had done since 861. In 1501, the Safavid dynasty of Iran subdued the Shirvanshahs and gained its possessions. In the course of the next century, the Safavids converted the formerly Sunni population to Shia Islam, as they did with the population in what is modern-day Iran. The Safavids allowed the Shirvanshahs to remain in power, under Safavid suzerainty, until 1538, when Safavid king Tahmasp I (r. 1524–1576) completely deposed them, and made the area into the Safavid province of Shirvan. The Sunni Ottomans briefly managed to occupy present-day Azerbaijan as a result of the Ottoman–Safavid War of 1578–1590; by the early 17th century, they were ousted by Safavid Iranian ruler Abbas I (r. 1588–1629). In the wake of the demise of the Safavid Empire, Baku and its environs were briefly occupied by the Russians as a consequence of the Russo-Persian War of 1722–1723. Remainder of present Azerbaijan was occupied by the Ottomans from 1722 to 1736. Despite brief intermissions such as these by Safavid Iran's neighboring rivals, the land of what is today Azerbaijan remained under Iranian rule from the earliest advent of the Safavids up to the course of the 19th century.
startend:quotation, detectable_format:number_bullet_lists[7], length_constraints:number_paragraphs[3]