239x239px|thumb|direita|Mausoléu dos Xãs de Xirvão, em Bacu, capital do país. A história do Azerbaijão é entendida como a história da região que agora forma a República do Azerbaijão. Topograficamente, a terra é contida pelas encostas do sul das montanhas do Cáucaso no norte, o Mar Cáspio no leste e as Terras Altas da Armênia no oeste. No sul, suas fronteiras naturais são menos distintas, e aqui o país se funde com o planalto iraniano.

O Reino da Albânia foi estabelecida nos tempos antigos. A língua cáucaso-albanesa falada pelos fundadores foi provavelmente um antecessor da agora ameaçada língua udi falada pelos udis. Desde da época do Império Medo e do Império Aquemênida, até a chegada dos russos no , os territórios do Azerbaijão e do Irã geralmente compartilhavam a mesma história. O Azerbaijão manteve seu caráter iraniano mesmo após a conquista árabe do Irã e a conversão dos habitantes da área ao Islã.

Cerca de quatro séculos depois, tribos turcomanas oguzes sob a dinastia seljúcida entraram na área, e o Azerbaijão ganhou uma grande quantidade de habitantes turcomanos. Ao longo dos séculos, à medida que a população original se misturava com os nômades turcos imigrantes, o número de falantes nativos de persa diminuiu gradualmente, e um dialeto túrquico hoje conhecido como azerbaijano (ou turco azeri) ganhou força. Uma das dinastias regionais, os Shirvanshahs, depois de se tornarem um estado sob o teto do Império Timúrida, ajudaram os Timúridas na guerra contra o Canato da Horda Dourada.

A inclusão do Azerbaijão no Grande Império Seljúcida no século 11 desempenha um papel importante na formação do povo Azerbaijano.  A formação da nação do Azerbaijão termina no século XIIISwietochowski, Tadeusz (1985). Russian Azerbaijan, 1905–1920: The Shaping of a National Identity in a Muslim Community. Cambridge University Press. p. 1.

No início do século 11, a região foi gradualmente invadida por ondas de turcos Oghuz da Ásia Central, que nessa época adotaram um nome étnico turcomano. A primeira dessas dinastias turcas foi o Império Seljúcida, que entrou no Azerbaijão em 1067.Barthold, V.V. Sochineniya; p. 558: "Whatever the former significance of the Oghuz people in Eastern Asia, after the events of the 8th and 9th centuries, it focuses more and more on the West, on the border of the Pre-Asian cultural world, which was destined to be invaded by the Oghuz people in the 11th century, or, as they were called only in the west, by the Turkmen."

Após a morte de Timur, dois estados turcos independentes e rivais surgiram na região: Qara Qoyunlu e Aq Qoyunlu.  Aq Qoyunlu e Qara Qoyunlu consistiam principalmente de tribos turcas de língua azeri e tinham uma estrutura confederada de dois estados.M.Behrâmnejâd, « Karakoyunlular, Akkoyunlular : İran ve Anadolu'da Türkmen Hanedanları », (turc) sh.  14 : "En raison de la domination des Turkmènes Qaraqoyunlu et Aqqoyunlu dans la région, de nombreuses tribus turkmènes s'y sont installées, et les autres ont établi l'État safavide en Iran. Aujourd'hui, une partie de l'héritage important qu'ils nous ont donné est Gunchikhan Oghuz ou Turkman, qui est utilisé dans certaines régions de Gunchikhan Anatolie, principalement à Igdir et Kars, ainsi qu'en Iran et en Azerbaïdjan, qui sont maintenant appelés Azerbaïdjanais.M. Faruk Sümer, «Kara Koyunlular»,(Turc) s. VIII: Les Karakoyunlus ne sont pas seulement responsables de ces mouvements migratoires politiques de l'Anatolie vers l'Iran, mais aussi le premier agent d'un nouveau mouvement de colonisation qui assurera la reprise de la domination turkmène en Iran et, en lien avec celle-ci, la turquification absolue de l'Azerbaïdjan .. ils l'ont été.  Comme on peut le comprendre à partir de ces mots, le turc qu'ils parlaient était, bien sûr, le dialecte oriental Oguz ou turkmène, qui s'appelle aujourd'hui le dialecte azéri.  Aujourd'hui, il est clairement entendu que Cihan Shah, l'un des dirigeants de Karakoyunlu, était l'un des représentants de la littérature azerbaïdjanaiseMiklukho-Maklay, N. D. Shiism and its social face in Iran at the turn of the XV-XVI centuries "These tribes, which later became known as the Qizilbash tribes... created the states of Kara Koyunlu and Ak Koyunlu, which in the 15th century successively ruled Azerbaijan and most of Iran Alguns historiadores são da opinião de que são azerbaijanos modernosGerhard doerfer, Turks in Iran, p.  248 It is very strange that the word "Turkmen" still leads to confusion. I saw in Leningrad that Iraqi Oghuz literature included the name Oghuz "Turkmen"; the word "Turkmen" actually means "nomadic Oghuz." In any case, the "Turkmen" of Aq qoyunlu and Qaraqoyunlu are Azerbaijanis.Г.Д Мuклухо-Маклаū, Шuuзм u еso соцо Иране на рубеже ХV-XVI  ьь. : "As a result, these tribes, called Qizilbash, were related to the Azerbaijani tribes, who by their languages ​​and origins established the Qaraqoyunlu and Aqqoyunlu states, and ruled Azerbaijan and much of Iran in the 15th century." Os Shirvanshahs, por outro lado, tornaram-se novamente independentes nesse processo e fortaleceram seus governos locais.

A língua principal dos governantes safávidas era o azeri, falado no palácio safávida até o colapso do estado. Price, Massoume (2005). Iran's Diverse Peoples: A Reference Sourcebook. ABC-CLIO. p. 66. ISBN 978-1-57607-993-5. "The Shah was a native Turkic speaker and wrote poetry in the Azerbaijani language."Savory, Roger (2007). Iran Under the Safavids. Cambridge University Press. p. 213. ISBN 978-0-521-04251-2. "qizilbash normally spoke Azari brand of Turkish at court, as did the Safavid shahs themselves; lack of familiarity with the Persian language may have contributed to the decline from the pure classical standards of former times"«Mission to the Lord Sophy of Persia, (1539- 1542) / Michele Membré ; translated with introduction and notes by A.H. Morton», p. 10-11 Os senhores feudais do estado consistiam nas tribos Qizilbash de língua azerbaijana. e eles tinham a vantagem na administração do estado.  eles também constituíam o exército estatal dos safávidasRoger Savory (2007). Iran Under the Safavids. Cambridge University Press. p. 213. ISBN 978-0-521-04251-2. qizilbash normally spoke Azari brand of Turkish at court, as did the Safavid shahs themselves; lack of familiarity with the Persian language may have contributed to the decline from the pure classical standards of former timesDavid Blow. Shah Abbas: The Ruthless King Who Became an Iranian Legend. — С. 165. The primary court language remained Turkish. But it was not the Turkish of Istambul. It was a Turkish dialect, the dialect of the Qizilbash Turkomans, which is still spoken today in the province of Azerbaijan, in north-western Iran.Zabiollah Safa (1986), "Persian Literature in the Safavid Period", The Cambridge History of Iran, vol. 6: The Timurid and Safavid Periods. Cambridge: Cambridge University Press, ISBN 0-521-20094-6, pp. 948–65. P. 950: "In day-to-day affairs, the language chiefly used at the Safavid court and by the great military and political officers, as well as the religious dignitaries, was Turkish, not Persian; and the last class of persons wrote their religious works mainly in Arabic. Those who wrote in Persian were either lacking in proper tuition in this tongue, or wrote outside Iran and hence at a distance from centers where Persian was the accepted vernacular, endued with that vitality and susceptibility to skill in its use which a language can have only in places where it truly belongs."Willem Floor, Hasan Javadi, The Role of Azerbaijani Turkish in Safavid Iran. Оригинальный текст (англ.) During the Safavid period Azerbaijani Turkish,or,as it was also referred to at that time, Qizilbash Turkish, occupied an important place in society, and it was spoken both at court and by the common people... Throughout the Safavid period there were two constants to Azerbaijani Turkish as a spoken language in Iran. First, it was and remained the official language of the royal court during the entire Safavid period. Second, the language remained the spoken language of the Turkic Qizilbash tribes and was also spoken in the army.

Após a desintegração do Império Afshar em 1747, os (Khanates do Azerbaijão) surgiram canatos (reinos) de origem azerbaijana no Azerbaijão e no Azerbaijão iraniano. este período é considerado o período de fragmentação feudal do Azerbaijão.Firouzeh Mostashari. On the religious frontier: Tsarist Russia and Islam in the Caucasus. I.B. Tauris; New York, 2006. ISBN 1-85043-771-8.The Caucasian Campaigns and the Azerbaijani Khanates The success of the Russian campaigns in annexing the Transcaucasian territories was not solely due to the resolve of the generals and their troops, or even their superiority over the Persian military. The independent khanates, themselves, were disintegrating from within, helplessly weakening one another with their internal rivalries.Alexander Murinson. Turkey’s Entente with Israel and Azerbaijan. Routledge, 2009. P. 2.The core territory of modern-day Azerbaijan, i.e. Shirvan, Quba and other Azeri Khanates in the Caucasus, served historically as place of refuge for Persian and later Russian Jews.

O período dos canatos é considerado o período de fragmentação feudal do Azerbaijão. Assim começou o período de meio século de independência do Azerbaijão, embora em condições de profunda desintegração política e guerra civil.Tadeusz Swietochowski. Russian Azerbaijan, 1905—1920: The Shaping of National Identity in a Muslim Community. Cambridge, UK, Cambridge University Press, 2004. ISBN 0-521-52245-5: Thus began a half-century-long period of Azerbaijani independence, albeit in a condition of deep political fragmentation and internal warfare. Most of the principalities were organized as khanates, small replicas of the Persian monarchy, including Karabagh, Sheki, Ganja, Baku, Derbent, Kuba, Nakhichevan, Talysh, and Erivan in northern Azerbaijan and Tabriz, Urmi, Ardabil, Khoi, Maku, Maragin, and Karadagh in its southern part. Many of the khanates were subdivided into mahals (regions), territorial units inhabited by members of the same tribe, reflecting the fact that residue of tribalism was still strong.

Cerca de quatro séculos depois, tribos turcomanas oguzes sob a dinastia seljúcida entraram na área, e o Azerbaijão ganhou uma grande quantidade de habitantes turcomanos. Ao longo dos séculos, à medida que a população original se misturava com os nômades turcos imigrantes, o número de falantes nativos de persa diminuiu gradualmente, e um dialeto túrquico hoje conhecido como azerbaijano (ou turco azeri) ganhou força. Uma das dinastias regionais, os Xãs de Xirvão, depois de se tornarem um estado sob o teto do Império Timúrida, ajudaram os Timúridas na guerra contra o Canato da Horda Dourada. Após a morte de Tamerlão, dois estados turcos independentes e rivais emergiram na região, a saber, Confederação do Cordeiro Negro e Confederação do Cordeiro Branco. Os Xãs de Xirvão, por outro lado, tornaram-se independentes novamente nesse processo e fortaleceram seus governos locais.