History of Azerbaijan

The history of Azerbaijan is understood as the history of the region now forming the Republic of Azerbaijan. Topographically, the land is contained by the southern slopes of the Caucasus Mountains in the north, the Caspian Sea in the east, and in the west. In the south, its natural boundaries are less distinct, and here the country merges with the Iranian Plateau.

The entity of Caucasian Albania was established on its soil in ancient times. The Caucasian Albanian language spoken by the founders of Caucasian Albania was most likely a predecessor of the now endangered Udi language spoken by the Udi people. From the time of the Medes and the Achaemenid Empire, until the coming of the Russians in the 19th century, the territories of the republic of Azerbaijan and Iran have usually shared the same history. Azerbaijan retained its Iranian character even after the Arab conquest of Iran and the conversion of the area's inhabitants to Islam. Some four centuries later, Oghuz Turkic tribes under the Seljuq dynasty entered the area, and Azerbaijan gained a large amount of Turkic inhabitants. Over the centuries, as the original population mingled with the immigrant Turkic nomads, the number of native Persian speakers gradually diminished, and a Turkic dialect nowadays known as Azerbaijani (or Azeri Turkic) gained hold.

One of the regional dynasties, the Shirvanshahs, after becoming a state under the roof of the Timurid Empire, helped the Timurids in the war against the Golden Horde State. After Timur's death, two Turkic independent and rival states emerged in the region, namely Qara Qoyunlu and Aq Qoyunlu. The Shirvanshahs, on the other hand, became independent again in this process and strengthened their local governments.

After the Russo-Persian wars of 1804–1813 and 1826–1828, Qajar Iran was forced to cede its Caucasian territories to the Russian Empire; the treaties of Gulistan in 1813 and Turkmenchay in 1828 defined the border between Czarist Russia and Qajar Iran. The region north of the Aras was Iranian until it was occupied by Russia during the 19th century. According to the Treaty of Turkmenchay, Qajar Iran recognized Russian sovereignty over the Erivan, Nakhchivan and Talysh Khanates (the last parts of Azerbaijan still in Iranian hands).

In the ensuing period, in post-Iranian Russian-held East Caucasia, an Azerbaijani national identity emerged at the end of the 19th century. After more than 80 years of being part of the Russian Empire in the Caucasus, the Azerbaijan Democratic Republic was established in 1918. The name "Azerbaijan", adopted by the ruling Musavat Party for political reasons, had been used to identify the adjacent region of northwestern Iran. Azerbaijan was invaded by Soviet forces in 1920, which led to the establishment of the Azerbaijan SSR. In the early Soviet period, the Azerbaijani national identity was finally forged. Azerbaijan remained under Soviet rule until the 1991 collapse of the Soviet Union, after which the independent Republic of Azerbaijan was proclaimed. Hostile relations with the neighboring Armenia and the Nagorno-Karabakh conflict have been focal points within Azerbaijani politics since independence.

Prehistory


Azerbaijani prehistory includes Stone, Bronze and Iron Ages with the Stone Age divided into Paleolithic, Mesolithic, and Neolithic eras and the Chalcolithic era being a transitional period from the Stone age to the Bronze and Iron Ages.

Early prehistory
The Paleolithic era is divided into three periods: lower, middle, and upper. The era began with the first human habitation in the region and lasted until the 12th millennium BCE. The Azykh Cave in Khojavend District is the site of one of Eurasia's oldest archaic-human habitations.(this cave is found in Armenia's old territory that it has owned for thousands of years.) Remnants of pre-Acheulean culture at least 700,000 years old were found in the lowest layers of the cave. In 1968, Mammadali Huseynov discovered a 300,000-year-old partial jawbone from an early human in the Acheulean-age cave layer; it is one of the oldest human remains ever discovered in the territory of the former Soviet Union. Azerbaijan's lower Paleolithic is known for the Guruchay culture, which has features similar to the culture of Tanzania's Olduvai Gorge.

The Mesolithic era from approximately 12,000 to 8,000 BCE, is represented by caves in Gobustan National Park (near Baku) and Damjili (in Qazax District). Rock carvings in Gobustan depict scenes of hunting, fishing, work and dancing. The newly excavated settlement of Osmantəpə in the Nakhchivan Autonomous Republic(was territory of Armenia before Azerbaijan) seems to cast light on the intermediate stage between the Mesolithic and Neolithic era.

The Neolithic era from the seventh and sixth millennia BCE, is represented by the Shulaveri–Shomu culture in Aghstafa District; finds at Damjili, Gobustan, Kultepe (in Nakhchivan) and Toyretepe, and the Neolithic Revolution in agriculture.

Petroglyphs dating from 8,000 to 5,000 years ago depict long boats (similar to Viking ships), indicating a connection with Continental Europe and the Mediterranean Sea.

Later prehistory
The Chalcolithic era lasted from the sixth to the fourth millennium BCE, was the period of transition from the Stone Age to the Bronze Age. The Caucasus Mountains are rich in copper ore, facilitating the development of copper smelting in Azerbaijan. A number of Chalcolithic settlements in Shomu-tepe, Toyratepe, Jinnitepe, Kültepe, Alikomektepe and IIanlitepe have been discovered, and carbon-dated artifacts indicate that inhabitants built homes, made copper tools and arrowheads, and were familiar with non-irrigated agriculture.

The Bronze Age in Azerbaijan began in approximately the second half of the fourth millennium BCE and the Iron Age began in approximately the seven and sixth centuries BCE. The Bronze Age is divided into early, middle and late eras and have been studied in Nakhchivan, Ganja, Mingachevir and Dashkasan District. The early Bronze Age is characterized by the Kura–Araxes culture, and the middle Bronze Age by painted earthenware or pottery culture. The late Bronze Age is demonstrated in Nakhchivan and by the Khojali–Gadabay and Talish–Mughan cultures.

Research in 1890 by Jacques de Morgan in the mountains of Talysh, near Lankaran, revealed over 230 late-Bronze and early-Iron Age burials. E. Rösler discovered late-Bronze Age materials in Karabakh and Ganja between 1894 and 1903. J. Hummel conducted research from 1930 to 1941 in Goygol District and Karabakh at sites known as Barrows I and II and other late-Bronze Age sites. Archaeologist Walter Crist of the American Museum of Natural History discovered a 4,000-year-old, Bronze Age version of hounds and jackals in Gobustan National Park in 2018. The game, popular in Egypt, Mesopotamia and Anatolia at the time, was identified in the tomb of Egyptian pharaoh Amenemhat IV.

Antiquity
The Achaemenids (persians not Azeris) were defeated by Alexander the Great in 330 BCE. After the 247 BCE fall of the Seleucid Empires in Persia, the Kingdom of Armenia ruled portions of what is today Azerbaijan from 190 BCE to 428 CE. The Arsacid dynasty of Armenia was a branch of the Parthian Empire, and Caucasian Albania (present-day Azerbaijan and Dagestan) was under Parthian rule for the next several centuries. The Caucasian Albanians established a kingdom in the 1st century BCE, primarily remaining a semi-independent vassal state until the Parthians were deposed in 252 and the kingdom became a province of the Sasanian Empire. Caucasian Albania's King Urnayr adopted Christianity as the state religion during the fourth century, and Albania was a Christian state until the eighth century. Although it was subordinate to Sasanid Persia, Caucasian Albania retained its monarchy. Sasanid control ended with its 642 defeat by the Rashidun Caliphate in the Muslim conquest of Persia.

The migration and settlement of Eurasian and Central Asian nomads has been a regional pattern in the history of the Caucasus from the Sassanid-Persian era to the 20th-century emergence of the Azerbaijani Turks. Among the Iranian nomads were the Scythians, Alans and Cimmerians, and the Khazars and Huns made incursions during the Hunnic and Khazar eras. Derbent was fortified during the Sasanid era to block nomads from beyond the North Caucasus pass who did not establish permanent settlements.

Achaemenid and Seleucid rule
After the overthrow of the Median Empire, Azerbaijan was invaded by the Persian king Cyrus the Great in the 6th century BCE and integrated into the Achaemenid empire. This early Persian rule enabled the rise of Zoroastrianism and other Persian cultural influences. Many Caucasian Albanians came to be known as fire worshippers, a Zoroastrian practice.

Caucasian Albania, Parthians, and Sasanian conquest


The Albanian kingdom coalesced around a Caucasian identity to forge a state in a region of empire-states. During the second or first century BCE the Armenians curtailed the southern Albanian territories and conquered Karabakh and Utik, inhabited by Albanian tribes who included the Utians, Gargarians and Caspians. At this time, the border between Albania and Armenia was the Kura.

As the region became an arena of wars when the Roman and Parthian Empires began to expand, most of Albania was briefly dominated by Roman legions under Pompey; the south was controlled by the Parthians. A rock carving of what is believed to be the easternmost Roman inscription, by Legio XII Fulminata during the reign of Domitian, survives just south-west of Baku in Gobustan. Caucasian Albania then came fully under Parthian rule.

In 252–253, Caucasian Albania was conquered and annexed by the Sasanian Empire. A vassal state, it retained its monarchy; the Albanian king had no real power, however, and most civil, religious, and military authority was held by the Sasanid marzban. After the Sasanid victory over Rome in 260, the victory and the annexation of Albania and Atropatene were described in a trilingual inscription by Shapur I at Naqsh-e Rostam.

Urnayr (343–371), related by marriage to Shapur II (309–379), held power in Albania. With a somewhat-independent foreign policy, he allied with the Sasanian Shapur. According to Ammianus Marcellinus, the Albanians provided military forces (particularly cavalry) to Shapur's armies in their attacks against Rome. The siege of Amida (359) ended in a Sasanian victory, and some Albanian regions were returned. Marcellinus noted that the Albanian cavalry played a role in the siege similar to that of the Xionites, and the Albanians were commended for their alliance with Shapur:

"Close by him [Šapur II] on the left went Grumbates, king of the Chionitae, a man of moderate strength, it is true, and with shriveled limbs, but of certain greatness of mind and distinguished by the glory of many victories. On the right was the king of the Albani, of equal rank, high in honour."

After the 387 division of Armenia between Byzantium and Persia, the Albanian kings regained control of the provinces of Uti and Artsakh (south of the Kur) when the Sasanian kings rewarded them for their loyalty to Persia.

Medieval Armenian historians such as Movses Khorenatsi and Movses Kaghankatvatsi wrote that the Albanians were converted to Christianity during the fourth century by Gregory the Illuminator of Armenia. Urnayr accepted Christianity, was baptised by Gregory, and declared Christianity his kingdom's official religion.

The Mihranids (630–705) arrived in Albania from Gardman during the early seventh century. Partav (now Barda) was the dynasty's administrative centre. According to M. Kalankatli, the dynasty was founded by Mehran (570–590) and Varaz Grigor (628–642) assumed the title of "prince of Albania".

Partav was Albania's capital city during the reign of Grigor's son, Javanshir (642–681), who demonstrated his allegiance early to Sasanian shah Yazdegerd III (632–651). He led the Albanian army as its sparapet from 636 to 642. Despite the Arab victory in the 637 battle of Kadissia, Javanshir fought as an ally of the Sasanians. After the 651 fall of the Sasanian Empire to an Arab caliphate, he shifted his allegiance to the Byzantine Empire three years later. Constans II protected Javanshir, who defeated the Khazars near the Kura in 662. Three years later the Khazars successfully attacked Albania, which became its tributary in exchange for the return of captives and cattle. Javanshir established diplomatic relations with the caliphate to protect his country from invasion via the Caspian Sea, meeting with Muawiyah I in Damascus in 667 and 670, and Albania's taxes were reduced. Javanshir was assassinated in 681 by rival Byzantine nobles. After his death, the Khazars again attacked Albania; Arab troops entered in 705 and put Javanshir's last heir to death in Damascus, ending the Mihrani dynasty and beginning caliphate rule.

Islamic conquest


Muslim Arabs defeated the Sasanian and Byzantine Empires as they marched into the Caucasus, making Caucasian Albania a vassal state after Javanshir's 667 surrender. Between the ninth and 10th centuries, Arab authors began calling the region between the Kura and Aras "Arran". Arabs from Basra and Kufa came to Azerbaijan, seizing abandoned lands.

At the beginning of the eighth century, Azerbaijan was the centre of the caliphate–Khazar–Byzantine wars. In 722–723, the Khazars attacked Arab Transcaucasian territory. An Arabian army led by Al-Jarrah ibn Abdallah drove the Khazars back across the Caucasus. Al-Jarrah fought his way north along the west Caspian coast, recovering Derbent and advancing with his army to the Khazar capital of Balanjar, captured the capital of the Khazar khanate and placed prisoners around Gabala. Then al-Jarrah returned to Sheki.

During the ninth century, the Abbasid Caliphate dealt with uprisings against Arab rule. The Khurramites, led by Babak Khorramdin, staged a persistent revolt. Babak's victories over Arab generals were associated with his seizure of Babak Fort, according to Arab historians who said that his influence extended to Azerbaijan: "southward to near Ardabil and Marand, eastward to the Caspian Sea and the Shamakhi district and Shervan, northward to the Muqan (Moḡan) steppe and the Aras riverbank, westward to the districts of Jolfa, Nakjavan, and Marand".

Feudal states in 9th-11th centuries
After the decline of the Abbasid Caliphate, the territory of the contemporary Azerbaijan Republic was ruled by dynasties Shaddadids, Shirvanshahs and the Salarid, Sajid, and Buyid dynasties.

The Shirvanshahs
Shirvanshah, Shīrwān Shāh or Sharwān Shāh, was the title of the rulers of Shirvan: a Persianized dynasty of Arab origin. The Shirvanshahs maintained a high degree of autonomy as local rulers and vassals from 861 to 1539, a continuity which lasted longer than any other dynasty in the Islamic world.

V.F Minorsky in his book titled "A History of Sharvan and Darband in the 10th–11th Centuries" distinguishes four dynasties of Shirvanshahs; 1. The Shirvanshahs (the Sassanids designated them for the protection of northern frontier); 2. Mazyadids; 3. Kasranids; 4. Derbent Shirvanshahs or Derbent dynasty.

At the end of the 10th – beginning of the 11th century they began wars with Derbent (this rivalry lasted for centuries), and in the 1030s they had to repel the raids of the Rus, and Alans.

The last ruler of the Mazyadid was Yazid ibn Ahmad, and from 1027 to 1382, the Kasranid dynasty began to rule the Shirvanshahs. In 1032 and 1033, the Alans attacked the territory of Shamakhi, but were defeated by the troops of the Shirvanshahs. The Kasranid dynasty ruled the state independently until 1066 when the Seljuk tribes came to their territory, and Shirvanshah I Fariburz accepted dependence on them, preserving internal independence.

Shirvan was reportedly independent during two periods: under the legendary sultan Manuchehr and Akhsitan I (who built Baku), and under the 15th-century House of Derbent. Between the 13th and 14th centuries, the Shirvanshahs were vassals of the Mongol and Timurid empires.

The Shirvanshahs Khalilullah I and Farrukh Yassar presided over a stable period during the mid-15th century, and Baku's Palace of the Shirvanshahs (which includes mausoleums) and the Khalwati Sufi khanqah were built during their reign. The Shirvanshahs were Sunnis, and opposed to the Shia Islam of the Safavid order. The Safavid leader Shaykh Junayd was killed in a 1460 skirmish with the Shirvanishah, leading to sectarian animosity.

Sajid dynasty
The Sajid dynasty was an Islamic dynasty that ruled from 879–880 until 941. The Sajids ruled Azerbaijan first from Maragha and Barda and then from Ardabil.

According to the Azerbaijani historian Abbasgulu aga Bakikhanov, from 908–909 to 919, the Sajids made the Shirvanshah Mazyadids dependent on them. Thus, at the beginning of the 10th century, the Sajid state included territories from Zanjan in the south to Derbent in the north, the Caspian Sea in the east, to the cities of Ani and Dabil in the west, covering most of the lands of modern Azerbaijan.

After the death of Yusuf ibn Abu Saj, the last ruler of the Sajid dynasty Deysam ibn Ibrahim was defeated by the ruler of Daylam (Gilan) Marzban ibn Muhammad who ended the Sajid dynasty and founded the Sallarid dynasty in 941 with its capital in Ardabil.

Sallarid dynasty
The Sallarid dynasty was an Islamic dynasty that ruled the territories of Azerbaijan, as well as Iranian Azerbaijan from 941 until 979.

In 943–944, the Russians organized a campaign to the Caspian region, which was many times more brutal than the 913/14 March. As a result of this campaign, which affected the economic situation in the region, Barda lost its position and essence as a large city and gave this position to Ganja.

The Sallaryid dynasty was forced to recognize the rule of the Shaddadids, which strengthened in Ganja in 971. Then, they were assimilated by the Seljuk Turks at the end of the 11th century.

Shaddadids
The Shaddadids were a Muslim dynasty that ruled the area between the rivers Kura and Araxes from 951 to 1199 AD.

Muhammad ibn Shaddad was considered the founder of the Shaddadid dynasty. Taking advantage of the weakening of Sallarids, Muhammad ibn Shaddad took control of the city of Dvin and established his state. The Shaddadids eventually extended their power over the territories of Azerbaijan and ruled major cities such as Barda and Ganja.

Fadl ibn Muhammad built the Khodaafarin Bridges along the Aras River to reconnect the territories between the north and south banks of Aras. In 1030, he organized an expedition against the Khazar khaganate.

In 1030, a new attack on Shirvanshahs by 38 Russian ships took place. Shirvanshah Manučehr was heavily defeated. At that time, Fadl I's son Askuya rebelled in Beylagan. Fadl I's loyal son Musa paid money to the Russians to save Beylagan. As a result, Askuya's revolt was suppressed, and he was executed.

Seljuks
The history of what comprises the present-day Republic of Azerbaijan as part of the Seljuk Empire may have been more pivotal than the Arab conquest since it helped shape the identity of modern Azerbaijani Turks. At the beginning of the 11th century, the region was occupied by waves of Oghuz Turks from Central Asia. The first Turkic rulers were the Ghaznavids from northern Afghanistan, who took over part of Azerbaijan by 1030. They were followed by the Seljuks, a western branch of the Oghuz Turks who conquered Iran and the Caucasus. The Seljuks pressed on to Iraq, where they overthrew the Buyids in Baghdad in 1055.

On September 30, 1139, a 7.7 earthquake struck Ganja, causing 200,000 to 300,000 deaths and great devastation.

The Seljuks then ruled an empire which included Iran and Azerbaijan until the end of the 12th century. During their rule, the sultan Nizam ul-Mulk (a noted Persian scholar and administrator) helped to introduce a number of educational and bureaucratic reforms. With his death in 1092 began the decline of the Seljuk empire, which hastened after the death of the sultan Ahmad Sanjar in 1153.

After Rawwadid Vahsudan, Togrul Bey came to Ganja and Abulasvar Shavur accepted his rule in 1054.

In 1075, Alp Arslan annexed the last of the Shaddadid territories. According to the anonymous Tariḵ Bab al-Abwab, Alp Arslan appointed al-Bab and Arran as iqta to his slave Sav Tegin who seized these areas by force from Fażlun in 1075 and ended the dynasty's reign. A branch of the Shaddadids continued to rule in the Ani emirate as vassals of the Seljuq Empire, while the others were assimilated by the Seljuqs.

Referring to the work of Minorsky, Azerbaijani historian Sara Ashurbeyli states that in 1066–67, during the reign of Shah Fariborz b. Sallār (1063–1096), ruler of Shirvanshahs, Seljuk Turks headed by commander Qarategin made great marches to Shamakhi and Baku, and then Shah I Fariburz accepted to be dependent on the Seljuks by paying 40,000 dinars a year.

The absence of the sultan's name on the coins minted during the reign of his son Akhsitan I indicates that the Seljuk state was already weakened and the Shirvanshahs were independent.

Seljuk possessions were ruled by atabegs, vassals of the Seljuk sultans who were sometimes de facto rulers themselves. The title of atabeg became common during Seljuk rule in the 12th century. From the end of the 12th to the early 13th century, Azerbaijan became a Turkic cultural centre. Palaces of the atabeg Eldiguz and the Shirvanshahs hosted distinguished guests, many of whom were Muslim artisans and scientists.

The Atabeks of Azerbaijan's power base was centered around Nakhchivan and would focus on Georgia. It expanded to Arran and took control of from Baylagan to Shamkir. He made himself virtually independent ruler of Azerbaijan by 1146. His marriage to the Mumine Khatun enabled him to intervene in the dynasty dispute between the Seljuk sultans of Iraq, which began after Masud's death in 1152.

After the death of Shamsaddin Eldaniz in Nakhchivan in 1175, his son Muhammad Jahan Pahlavan succeeded him. Pahlavan transferred the capital from Nakhchivan to Hamadan in western Iran and made his younger brother, Qizil Arslan Uthman, the ruler of Azerbaijan. In 1174, Qizil Arslan captured Tabriz, which subsequently became his capital.

After Muhammad Jahan Pahlavan's death, his brother Qizil Arslan (1186–1191) ascended the throne. He continued his successful struggle against the Seljuq rulers. At the same time, the central power began to get weaker as mamluks, who had strengthened their dominance in their areas, did not want to obey the Sultan. Even Shirvanshah Akhsitan I who used to be Atabegs' attempted to intervene in the interior affairs of the Eldiguzids and opposed Qizil Arslans aspiration to the throne. In the response to this, Qizil Arslan invaded Shirvan in 1191, reached to Derbent and subordinated the whole Shirvan to his authority. In 1191, Toghrul III, the last Seljuq ruler was overthrown by Qizil Arslan. Then, by Khalif's leave, he proclaimed himself a Sultan, and then he was poisoned by Innach Khatun in September, 1191.

The Eldiguzid atabeg Abu Bakr attempted to stem the Georgian advance, but suffered a defeat at the hands of David Soslan at the Battle of Shamkor and lost his capital to a Georgian protégé in 1195. Although Abu Bakr was able to resume his reign a year later, the Eldiguzids were only barely able to contain further Georgian forays. The State's defense capability was stricken. Khorezmshahs' and Georgians' non-stopping forays aggravated the situation in the country and speeded up its decay.

In 1225, Jalal ad-Din Mingburnu of the Khwarazmian dynasty ended Seljuk and atabeg rule and set himself up in the capital of Tabriz on the 25 of July in 1225.

Under the Seljuks, progress was made in poetry by the Persian poets Nizami Ganjavi (1141–1209), Mahsati Ganjavi (1089–1159) and Khaqani (1120–1199), who lived in this region, and mark the zenith of medieval Persian literature. The region experienced a building boom, and the unique Seljuk architecture is exemplified by the 12th-century fortress walls, mosques, schools, mausoleums, and bridges of Baku, Ganja, and the Absheron Peninsula.

Ajami Abubakr oglu Nakhchivani is one of the architects who lived and created in Azerbaijan during the Atabegs of Azerbaijan. Ajami, also known as "Sheikh al-Muhandis", was the architect of the several famous architectural monumentssuch as Yusif ibn Kuseyir Mausoleum, Momine Khatun Mausoleum and Juma Mosque and the founder of the Nakhichivan School of architecture. The mausoleums of Nakhichivan was nominated for the List of World Heritage Sites, UNESCO in 1998.

Mongols and Ilkhanate rule
The Mongol invasions and conquests of Azerbaijan took place during the 13th and 14th centuries and involved large-scale raids. The Mongol invasion of the Middle East and the Caucasus impacted Azerbaijan and most of its neighbors. Invasions resulted in the incorporation of the territories of Azerbaijan into the newly established Hulagu state with the capital of Maragha in 1256 and lasted until 1357.

During the first invasion of Azerbaijan by the Mongols in 1220–1223, cities such as Zanjan, Qazvin, Maragha, Ardebil, Bailagan, Barda, Ganja, which were the territory of the Atabegs of Azerbaijan, were destroyed.

The Mongol forces approached Tabriz and got a ransom from the city in 1221. After destroying the city of Maragha, they attacked Diyarbakir and Ardabil and then again returned to Azerbaijan. Thus, the Mongols marched to the north, plundering Shirvanen route. In addition, Beylagan was plundered in the spring of 1221. This took them through the Caucasus into Alania and the South Russian steppes where the Mongols routed the Rus'-Kipchak armies at the Battle of the Kalka River (1223).

The second invasion of the Mongolians to Azerbaijan is connected with the name of Chormagan Noyon- a military commander of Genghis Khan in the 1230s. This march was organized by the order of the great Khan Ögedei against Jalâl ad-Dîn Khwârazmshâh, who was ruling these areas after putting an end to Atabek's power in Azerbaijanin 1225. Ögedei Khan sent 30,000 men under the command of Chormagan and the Khwarazmians were swept away by the new Mongol army. In 1231, the Mongols occupied most of Azerbaijan Four years later, they destroyed cities of Ganja, Shamkir, Tovuz, and Şabran on their way to Kievan Rus'. By 1236, Transcaucasia was in the hands of Ögedei Khan.

The third invasion of territories of Azerbaijan by Mongolians is associated with the name of Hulagu khan. After his brother Möngke's accession as Great Khan in 1251. The state established in the areas of modern Iran, Azerbaijan, Turkey, and parts of modern Iraq, Syria, Armenia, Georgia, Afghanistan, Turkmenistan, Pakistan, was an attempt to repair of the damage of the previous Mongol invasions.

Thus, the territories of Azerbaijan became a battleground between the Golden Horde and the Hulagu states.

After the death of Abu Sa'id, the Chobanids dynasty ruled over Azerbaijan, Arrān, and parts of Asia Minor, Mesopotamia, and west central Persia from 1335 to 1357, until the death of Malek Ashraf.

In 1364 Shaykh Uways Jalayir campaigned against the Shirvan Shah Kai-Ka'us, but a revolt begun by the governor of Baghdad, Khwaja Mirjan, forced him to return to reassert his authority. In 1366 Shaykh Uways Jalayir marched against the Kara Koyunlu, defeating their leader, Bairam Khwaja, at the battle of Mush. Later, he defeated the Shirvan Shah. Then, he was succeeded by his son Shaikh Hasan Jalayir.

End of Mongol rule and Kara Koyunlu-Aq Qoyunlu rivalry
Timur (Tamurlane) invaded Azerbaijan during the 1380s, temporarily incorporating it into his Eurasian domain. Shirvan, under Ibrahim I of Shirvan, was also a vassal state of Timur and assisted him in his war with the Mongol ruler Tokhtamysh of the Golden Horde. Azerbaijan experienced social unrest and religious strife during this period due to sectarian conflict initiated by Hurufism, the Bektashi Order, and other movements.

After Timur's death in 1405, Shah Rukh (his fourth son) reigned until his death in 1447. Two rival Turkic rulers emerged west of his domain: the Qara Qoyunlu (based around Lake Van) and the Aq Qoyunlu, centred around Diyarbakır. The Kara Koyunlu were ascendant when their chief, Qara Yusuf, overcame Sultan Ahmed Mirza (the last of the Jalayirids), conquered lands south of Azerbaijan in 1410, and established his capital at Tabriz. Under Jahan Shah, they expanded into central Iran and as far east as Greater Khorasan. The Aq Qoyunlu became prominent under Uzun Hasan, overcoming Jahan Shah and the Qara Qoyunlu. Uzun Hasan ruled Iran, Azerbaijan, and Iraq until his death in 1478. The Aq Qoyunlu and Qara Qoyunlu continued the Timurid tradition of literary and artistic patronage, illustrated by Tabriz' Persian miniature paintings.

Safavid Empire and the rise of Shia Islam


The Safavid order was a Sufi religious order based in Iran and formed during the 1330s by Safi-ad-din Ardabili (1252–1334), for whom it was named. The order converted to Twelver Shia Islam by the end of the 15th century. Some Safavid followers (notably the Qizilbash) believed in the mystical and esoteric nature of their rulers and their relationship to the house of Ali, and were willing to fight for them. The Safavid rulers claimed to be descended from Ali and his wife, Fatimah (the daughter of Muhammad), through the seventh Imam Musa al-Kadhim. Qizilbash numbers increased by the 16th century; their generals waged a successful war against the Aq Qoyunlu, and captured Tabriz.

The Safavids, led by Ismail I, expanded their base in Ardabil; they conquered the Caucasus, parts of Anatolia, Mesopotamia, Central Asia, and western portions of South Asia. Ismail sacked Baku in 1501 and persecuted the Sunni Shirvanshahs. Azerbaijan, Armenia, and Dagestan were conquered by the Safavids between 1500 and 1502.

During the reign of Ismail I and his son, Tahmasp I, Shia Islam was imposed upon the Sunni population of Iran and Azerbaijan. The conversion was especially harsh in Shirvan, where many Sunnis were massacred. Safavid Iran became a feudal theocracy during this period, and the shah was held to be the divinely-ordained head of the state and its religion. The Qizilbashi chiefs were designated wakils (provincial administrators), and the position of ulama was created. Wars with the rival Sunni Ottoman Empire continued during the reign of Tahmasp I, and the Safavid cities of Shamakha, Ganja, and Baku were occupied by the Ottomans during the 1580s.

Under Abbas the Great (1587–1630), the monarchy assumed a Persian Shiite identity. Abbas' reign was the Safavid zenith, and he repelled the Ottomans and re-captured the Caucasus (including Azerbaijan) between 1603 and 1607. Aware of Qizilbash power, Abbas continued the policy of integrating the Caucasus into Persian society and deported hundreds of thousands of Circassians, Georgians and Armenians to Iran. They served in the army, the royal house and in civil administration, effectively killing the feudal Qizilbash; the converted Caucasians (known as ghulams) were loyal to the shah, not their tribal chiefs. Their Armenian, Georgian, and Circassian descendants still live in Iran. The religious impact of Safavid Iran was significant in Azerbaijan due to its early-16th century conversion to Shia Islam, and the country has the world's second-largest population of Shiites (by percentage, after Iran).

18th- and early 19th-century khanates and cession to Russia
As civil conflicts took hold in Iran, most of Azerbaijan was occupied by the Ottomans from 1722 to 1736. Between 1722 and 1735, during the reign of Peter the Great, the Caspian coast (including Derbent, Baku and Salyan) came under Imperial Russian rule as a result of the Russo-Persian War.

After the collapse of Safavid Iran, Nader Shah (an Iranian military man of Turkoman origin) came to power. He seized Iran, banished the Afghans in 1729, and marched as east as Delhi in the hope of founding another Persian empire. Not fortifying his Persian base, however, exhausted Nader's army. He controlled Shah Tahmasp II and was regent of the infant Abbas III until 1736 when he had himself crowned as shah on the Mugan plain. Nader quickly established a new Iranian empire, amassing territory unknown since the Sasanians. He conquered the Caucasus, Mesopotamia, portions of Anatolia, large parts of Central Asia, and defeated the Mughals in the Battle of Karnal. Nader sacked Delhi, the Mughal capital, and brought much wealth back to Persia. Although his empire was short-lived, he is considered Asia's last great conqueror.

Nader Shah's Afsharid dynasty disintegrated after his assassination in 1747, and several Turkic khanates with varying degrees of autonomy emerged in the region. The eunuch Agha Mohammad Khan Qajar turned to the restoration of the outlying Safavid and Afsharid provinces. Returning to Tehran in the spring of 1795, he assembled a force of about 60,000 cavalry and infantry and set off for Azerbaijan in May. He intended to reconquer all territory lost to the Ottomans and Russians, including the region between the Aras and Kura formerly under Iranian Safavid and Afsharid control. The region contained a number of khanates, of which the most important was Karabakh (with its capital at Shusha); Ganja; Shirvan, across the Kura, with its capital at Shamakhi; and Christian Gurjistan (Georgia), on both banks of the Kura in the north-west with its capital at Tiflis. All were under nominal Persian suzerainty. The khanates warred constantly among themselves and against external threats. The most powerful northern khan was Fat'h Ali Khan of Quba (died 1783), who united most of the neighbouring khanates and mounted an expedition to seize Tabriz from the Zand dynasty. The Karabakh Khanate subdued neighbouring Nakhchivan and portions of Erivan.

Agha Mohammad Khan was victorious in the civil war which began with the death of the last Zand king. His reign is noted for the re-emergence of a united Iran. After the death of Nader Shah and the last of the Zands, most of Iran's Caucasian territories had broken away and formed khanates. Agha Mohammad Khan (like the Safavid kings and Nader Shah before him) viewed the region as no different from Iran, and his first objective after securing Iran was to reincorporate the Caucasus into it. Georgia was seen as an integral territory. For Agha Mohammad Khan, the subjugation and reintegration of Georgia into the Iranian empire was part of the process which brought Shiraz, Isfahan, and Tabriz under his rule. According to The Cambridge History of Iran, Georgia's secession was inconceivable; it had to be resisted like an attempt at separating Fars or Gilan Province. Agha Mohammad Khan did whatever was necessary to subdue and reincorporate the recently-lost regions after Nader Shah's death and the fall of the Zands, including suppressing what was seen as treason by the wali of Georgia: King Heraclius II, who was appointed viceroy of Georgia by Nader Shah.

Agha Mohammad Khan demanded that Heraclius II renounce the Treaty of Georgievsk, which had been signed several years earlier, denouncing dependence on Persia and agreeing to Russian protection and assistance in its affairs. He demanded that Heraclius II again accept Persian suzerainty in return for peace and security. The Ottomans, Iran's neighbouring rival, recognized Iranian rights to Kartli and Kakheti for the first time in four centuries. Heraclius appealed to Empress Catherine II of Russia for at least 3,000 Russian troops; although he received no response (leaving Georgia to fend off Persia alone), he rejected Agha Mohammad Khan's ultimatum. Agha Mohammad Khan invaded the Caucasus, crossing the Aras and recapturing Shirvan, the Erivan, Nakhchivan, Derbent, Talysh, Shaki and Karabakh Khanates, and Igdir. The Battle of Krtsanisi resulted in the sack of Tiflis and the reintegration of Georgia into Iran. When he returned with 15,000 to 20,000 Georgian captives, Agha Mohammad was crowned shah in 1796 on the Mughan plain, as Nader Shah had been sixty years earlier.

He was assassinated while preparing a second expedition against Georgia in 1797 in Shusha, and Heraclius II died early the following year. Iranian rule of Georgia was short-lived; in 1799, the Russians marched into Tbilisi. Russia had pursued a policy of expansion with its southern neighbours (the Ottoman Empire and Iran) since the late 17th and early 18th centuries. The two years following Russia's entrance into Tbilisi were a time of confusion, and Georgia was absorbed by Russia in 1801. Iran would not allow the cession of Transcaucasia and Dagestan, leading to the Russo-Persian War of 1804-1813 and the 1826-1828. Eastern Georgia, Dagestan, Armenia, and Azerbaijan were ceded to Russia in the 1813 Treaty of Gulistan and the 1828 Treaty of Turkmenchay. Although the 1804–1813 Russo-Persian War disrupted trade and agriculture in the Caucasus, the 1826–1828 war was primarily fought in Iran. As a result of the wars, long-standing ties between Iran and the region were severed during the 19th century.

Tadeusz Swietochowski wrote, "The brief and successful Russian campaign of 1812 was concluded with the Treaty of Gulistan, which was signed on October 12 of the following year. The treaty provided for the incorporation into the Russian Empire of vast tracts of Iranian territory, including Daghestan, Georgia with the Sheragel province, Imeretia, Guria, Mingrelia, and Abkhazia (latter four regions were vassals of Ottomans), as well as the khanates of Karabagh, Ganja, Sheki, Shirvan, Derbent, Kuba, Baku, and Talysh."

Svante Cornell wrote, "In 1812 Russia ended a war with Turkey and went on the offensive against Iran. This led to the treaty of Gulistan in 1813, which gave Russia control over large territories that hitherto had been at least nominally Iranian, and moreover a say in Iranian succession politics. The whole of Daghestan and Georgia, including Mingrelia and Abkhazia, were formally ceded to Russia, as well as eight Khanates in modern-day Azerbaijan (Karabakh, Ganja, Sheki, Kuba, Shirvan, Talysh, Baku, and Derbent). However, as we have seen the Persians soon challenged Russia's rule in the area, resulting in a military disaster. Iran lost control over the whole of Azerbaijan, and with the Turkemenchai settlement of 1828 Russia threatened to establish its control over Azerbaijan unless Iran paid a war indemnity. The British helped the Iranians with the matter, but the fact remained that Russian troops had marched as far as south of Tabriz. Although certain areas (including Tabriz) were returned to Iran, Russia was in fact at the peak of its territorial expansion."

According to The Cambridge History of Iran, "Even when rulers on the plateau lacked the means to effect suzerainty beyond the Aras, the neighbouring Khanates were still regarded as Iranian dependencies. Naturally, it was those Khanates located closest to the province of Āzarbāījān which most frequently experienced attempts to re-impose Iranian suzerainty: the Khanates of Erivan, Nakhchivān and Qarābāgh across the Aras, and the cis-Aras Khanate of Ṭālish, with its administrative headquarters located at Lankarān and therefore very vulnerable to pressure, either from the direction of Tabrīz or Rasht. Beyond the Khanate of Qarābāgh, the Khān of Ganja and the Vāli of Gurjistān (ruler of the Kartli-Kakheti kingdom of south-east Georgia), although less accessible for purposes of coercion, were also regarded as the Shah's vassals, as were the Khāns of Shakki and Shīrvān, north of the Kura river. The contacts between Iran and the Khanates of Bākū and Qubba, however, were more tenuous and consisted mainly of maritime commercial links with Anzalī and Rasht.

The effectiveness of these somewhat haphazard assertions of suzerainty depended on the ability of a particular Shah to make his will felt, and the determination of the local khans to evade obligations they regarded as onerous."

Transition from Iranian to Russian rule


According to Audrey L. Altstadt, Russia had been moving militarily towards the Caucasus since 1790. After its defeat by Russia, Qajar Iran ceded Dagestan, Georgia, and most of Azerbaijan to Russia. Local khanates were abolished (Baku and Ganja) or accepted Russian patronage.

The 1826–1828 Russo-Persian war resulted in another defeat for Iran. The Qajars ceded their remaining Caucasian territories: the remainder of Azerbaijan (the Nakhchivan and Lankaran Khanates) and Armenia's Erivan Khanate. Tariffs were lowered on Russian goods, and Russia could keep a navy in the Caspian Sea. The Treaty of Turkmenchay defined Russian-Iranian relations until 1917, establishing the present borders of Azerbaijan and Iran as khan rule ended. In the newly-Russian-controlled territories, two provinces were established which became most of present-day Azerbaijan: Elisavetpol (Ganja) in the west and Shamakhi District in the east. Azerbaijanis are now divided between Azerbaijan and Iran. The Russian conquest sparked an exodus of Caucasian Muslims toward Iran, including many Turkic peoples from north of the Aras.

Despite the Russian conquest, throughout the entire 19th century, preoccupation with Iranian culture, literature, and language remained widespread amongst Shia and Sunni intellectuals in the Russian-held cities of Baku, Ganja and Tiflis (Tbilisi, now Georgia). Within the same century, in post-Iranian Russian-held East Caucasia, an Azerbaijani national identity emerged at the end of the 19th century.

From the Russian conquests to the 1840s, Azerbaijan was governed by the Tsar's military. Russia reorganized the region's khanates into provinces, each governed by an army officer with a combination of local and Russian law. Due to the officers' unfamiliarity with local customs, however, Russian imperial law was increasingly applied; this led to local discontent. Russian administration was unequal to non-Christian Azerbaijanis; religious authorities were kept under control, disturbing non-Christians. Russia made concerted efforts to control the application of Islamic law, and two ecclesiastical boards were created to oversee Islamic activity; it appointed a mufti for the Sunni board and a shaykh al-Islām for its Shia counterpart. In 1857 Georgian and Armenian religious authorities were permitted to censor their respective communities, but Muslim religious works were approved by a censorship board in Odessa. Azerbaijani Turks were subject to Russian proselytizing.

During the late 1830s, plans were made to replace the military rule with a civil administration. When the new legal system became effective in January 1841, Transcaucasia was divided into a Georgian-Imeretian province and a Caspian oblast centered in Shamakhi. New administrative borders ignored historic borders or ethnic composition. By the end of military rule in Azerbaijan, Russian imperial law applied to all criminal and most civil matters; the jurisdiction of traditional religious courts and Qadis was reduced to family law. After an 1859 earthquake, the capital of the eastern province was transferred from Shamakhi to Baku.

Baku was integrated into the Russian Empire in accordance with the 1813 Treaty of Gulistan, and Azerbaijan experienced significant economic development during the second half of the 19th century. The separate currencies of the former khanates were replaced by the ruble, and their tariffs were abolished; these reforms encouraged further investment in the region. Russia began investing in joint-stock companies, and by the 1840s steamships began sailing on the Caspian. Trade in the port of Baku increased from an average of 400,000 rubles during the 1830s to 500,000 in the 1840s and 700,000 to 900,000 rubles after the Crimean War.

Although oil had been discovered and exported from the region centuries before, the 1870s Azerbaijani oil rush led to prosperity and growth in the years leading to World War I and created huge disparities in wealth between the largely-European capitalists and the local Muslim workforce. During the 1870s, Baku experienced rapid industrial growth due to the oil boom. Azerbaijan's first oil refinery was established near Baku in 1859, and the region's first kerosene plant was built in 1863. Oil wells built during the 1870s sparked the boom, and oilfields were auctioned. This system secured investors' holdings, encouraging further investment. Most of the investors were elite Russians and Armenians; of 51 oilfields sold at the first auction, five were bought by Azerbaijani Turks. Two of Baku's 54 notable 1888 oil-extraction firms were owned by Azerbaijanis, who participated in greater numbers in small-scale extraction and refining operations; 73 of 162 oil refineries were Azerbaijani-owned, but all except seven of them employed fewer than 15 people. In the decades after the oil rush (and its foreign investment), other industries grew in Azerbaijan. The banking system was one of the first to react to the oil industry. In 1880, an offshoot of the state bank opened in Baku. In its first year of operation, it issued 438,000 rubles; in 1899, all Baku banks had issued 11.4 million rubles in interest-bearing securities. Transportation and shipping also developed as a result of the expanding oil market, and the number of vessels on the Caspian quadrupled between 1887 and 1899. The Transcaucasus Railway, completed in 1884, connected Baku (on the Caspian Sea) to Batum on the Black Sea via Ganja (Elizavetpol) and Tiflis. In addition to transporting oil, the railroad develop new relationships between rural agricultural regions and industrial areas. The region was further interconnected with new communications infrastructure; telegraph lines connected Baku to Tiflis via Elizavetpol in the 1860s, and a telephone system operated in Baku during the 1880s.

Modernisation—compared to the neighboring Armenians and Georgians—was slow to develop amongst the Tatars of the Russian Caucasus. According to the 1897 Russian Empire census, less than five percent of the Tatars were able to read or write. The intellectual and newspaper editor Ali bey Huseynzade (1864–1940) led a campaign to 'Turkify, Islamise, modernise' the Caucasian Tatars, whereas Mammed Said Ordubadi (1872–1950), another journalist and activist, criticized superstition amongst Muslims.

The oil rush was spurred by Armenian magnate Ivan Mirzoev and his drilling practices. Oilfields were auctioned primarily to Russians, Armenians, and Europeans, most notably Robert Nobel of Branobel. By 1900, Baku's population increased from 10,000 to about 250,000 as a result of worker migration from the Russian Empire, Iran, and elsewhere. The growth of Baku fostered the emergence of an Azeri nationalist intelligentsia influenced by European and Ottoman ideas. Influential thinkers such as Hasan bey Zardabi, Mirza Fatali Akhundov and (later) Jalil Mammadguluzadeh, Mirza Alakbar Sabir, Nariman Narimanov encouraged nationalist discourse, railed against poverty, ignorance, and extremism, and sought reforms in education and the emancipation of dispossessed classes (including women). The financial support of philanthropic millionaires such as Haji Zeynalabdin Taghiyev bolstered the rise of an Azeri middle class.

An economic and political crisis erupted in Baku after the Russo-Japanese War, beginning with a general strike of oil workers in 1904. The following year, class and ethnic tensions resulted in Muslim-Armenian massacres during the 1905 Russian Revolution.

The situation improved between 1906 and 1914 when a limited parliamentary system was introduced in Russia and Muslim MPs from Azerbaijan promoted Azeri interests. The pan-Turkist and pan-Islamist Musavat Party,     inspired by Mammed Amin Rasulzade's left-wing modernist ideology, was formed in 1911. Clandestine at first, the party expanded rapidly in 1917 after Russia's October Revolution. Key components of Musavat ideology were secularism, nationalism and federalism, or autonomy within a broader political structure. The party's right and left wings differed on certain issues, however, most notably land distribution.

When Russia became involved in World War I, social and economic tensions spiked. Its 1917 revolution granted self-rule to Azerbaijan, but also renewed ethnic conflicts between Azeris and Armenians.

Azerbaijan Democratic Republic


When the Russian Empire collapsed in 1917, the Transcaucasian Federation was founded by Armenian, Azerbaijani and Georgian intelligentsia. The federation was short-lived, and the Azerbaijan Democratic Republic was proclaimed on 28 May 1918 by the Musavat. The name "Azerbaijan", adopted by the party for political reasons, had been used to identify the adjacent region of northwestern Iran.

It was the Islamic world's first democratic republic. In Baku, however, a coalition of Bolsheviks, Dashnaks and Mensheviks fought against a Turkish Islamic army led by Nuri Pasha. The coalition, known as the Baku Commune, inspired (or tacitly condoned) the massacre of local Muslims by Dashnak-Armenian forces. It collapsed, and was replaced by the British-controlled Centrocaspian Dictatorship in July 1918. After battles in August and September, the joint forces of the Azerbaijan Democratic Republic and Ottoman Empire (led by Nuri Pasha) entered Baku and declared it the Azerbaijani capital on 15 September 1918.

Azerbaijan was proclaimed a secular republic, and its first parliament met on 5 December 1918. Although the British administration initially did not recognize the republic, it cooperated with it. The situation in Azerbaijan had more or less stabilized by mid-1919, and British forces left in August of that year. However, advancing Bolshevik forces, victorious in the Russian Civil War, began to threaten the republic (involved in a conflict with Armenia over Karabakh) by early 1920.

Azerbaijan was recognised by the Allies as an independent nation in January 1920 at the Paris Peace Conference. The republic was governed by five cabinets, formed by a coalition of the Musavat, the Socialist Bloc, the Independents, the Liberals, the Hummet and the Ittihad parties. The premier of the first three cabinets was Fatali Khan Khoyski, and Nasib Yusifbeyli was premier of the last two. Parliamentary president Alimardan Topchubashov, the recognized head of state, represented Azerbaijan at the peace conference.

Aided by dissidents in government, the Red Army invaded Azerbaijan on 28 April 1920. Most of the newly formed Azerbaijani army was engaged in putting down an Armenian revolt which had broken out in Karabakh. The Azerbaijanis did not surrender their brief independence easily; as many as 20,000 died resisting what was essentially a Russian reconquest. The formation of the Azerbaijan Soviet Socialist Republic was facilitated by popular support of Bolshevik ideology, particularly by workers in Baku. On the day of the invasion, a Soviet government was formed under Nariman Narimanov. The same fate befell Armenia by the end of 1920, and Georgia in March 1921.

Soviet Azerbaijan
After the government surrendered to Bolshevik forces, Azerbaijan was proclaimed a Soviet socialist republic on 28 April 1920. The Congress of the Peoples of the East was held in Baku in September of that year. Nominally an independent state, the Azerbaijan SSR was dependent on (and controlled by) the government in Moscow. It was incorporated into the Transcaucasian Socialist Federative Soviet Republic, with Armenia and Georgia, in March 1922. In accordance with a December 1922 agreement, the TSFSR became one of the Soviet Union's four original republics. The TSFSR was dissolved in 1936, and its three regions became republics of the USSR. In the early Soviet period, the Azerbaijani national identity was finally forged.

Like other Union Republics, Azerbaijan was affected by Stalin's purges during the 1930s. Thousands of people were killed during the period, including Huseyn Javid, Mikail Mushfig, Ruhulla Akhundov, and Ayna Sultanova. The Azerbaijan SSR supplied much of the Soviet Union's gas and oil during World War II, and was a strategically important region. Although the June 1941 German invasion of the Soviet Union reached the Greater Caucasus in July 1942, the Germans did not invade Azerbaijan. The 1950s were a period of rapid urbanization and industrialization, and a sblizheniye (rapprochement) policy began to merge the peoples of the Soviet Union into a monolithic nation.

Azerbaijan's oil industry lost its relative importance to the Soviet economy during the 1960s because of a shift in oil production to other regions of the Soviet Union and the depletion of known terrestrial oil resources; offshore production was not considered cost-effective. Azerbaijan had the second-lowest rate of growth in productivity and economic output of the Soviet republics, ahead of Tajikistan. Although ethnic tensions (particularly between Armenians and Azerbaijanis) began to grow, violence was suppressed.

In an attempt to end the structural crisis, the government in Moscow appointed Heydar Aliyev as the first secretary of the Communist Party of Azerbaijan in 1969. Aliyev temporarily improved economic conditions and promoted alternative industries, such as cotton, to supplement the declining oil industry. He consolidated the republic's ruling elite (which now consisted almost entirely of ethnic Azerbaijanis), reversing the previous rapprochement. Aliyev was appointed a member of the Communist Party's Politburo in Moscow, the highest position attained by an Azeri in the Soviet Union, in 1982. In 1987, when Mikhail Gorbachev's perestroika began, he retired.

The Gorbachev era was marked by increasing unrest in the Caucasus, initially over Nagorno-Karabakh. Ethnic conflict, centering on Armenian demands for the unification of Azerbaijan's Nagorno-Karabakh Autonomous Oblast with Armenia by March 1988, began in February of that year amid pogroms against the Armenian populations of Baku and Sumgait. Although Moscow imposed military rule several times, unrest continued to spread.

The ethnic strife revealed the Communist Party's shortcomings as a champion of national interests, and independent publications and political organizations emerged in the spirit of glasnost. By fall 1989, the Popular Front of Azerbaijan (PFA) seemed poised to seize power from the Communist Party before the party split into conservative-Islamic and moderate wings. The split was followed by an outbreak of anti-Armenian violence in Baku and intervention by Soviet troops.

Unrest culminated in violent confrontation when Soviet troops killed 132 nationalist demonstrators in Baku on 20 January 1990. Azerbaijan declared independence from the USSR on 30 August 1991 and became part of the Commonwealth of Independent States. The First Nagorno-Karabakh War began by the end of the year, resulting in the creation of the self-declared separatist Republic of Artsakh, which persisted until 2023. The refusal by both sides to negotiate resulted in a stalemate, as Armenian troops retained their positions in Karabakh and corridors to Armenia which were seized from Azerbaijan.

Mutallibov presidency (1991–1992)
Azerbaijan SSR president Ayaz Mutallibov and Georgian president Zviad Gamsakhurdia were the only Soviet leaders to support the 1991 Soviet coup d'état attempt, and Mütallibov proposed constitutional changes to permit direct nationwide presidential elections. The 1991 Azerbaijani presidential election, in which Mutalibov was the only candidate, was held on 8 September 1991. Although the election was neither free nor fair by international standards, Mutalibov became the country's formal president. The proposed 18 October 1991 declaration of independence by Azerbaijan's Supreme Soviet was followed by the dissolution of its Communist Party, although its former members (including Mutallibov) retained their posts. In a nationwide December 1991 referendum, Azerbaijani voters approved the Supreme Soviet's declaration of independence. The country was first recognized by Turkey, Israel, Romania and Pakistan, and the United States followed suit on 25 December.

The Nagorno-Karabakh conflict continued, despite efforts to negotiate a settlement. Early in 1992, Karabakh's Armenian leadership proclaimed an independent republic. Armenia gained the upper hand in what was now a full-scale war, with covert assistance from the Russian Army. Atrocities were committed by both sides; the 25 February 1992 Khojaly massacre of Azerbaijani civilians was criticized for the government's inaction, and Azerbaijani troops killed and captured Armenian civilians in the Maraga massacre. Mütallibov, pressured by the Azerbaijani Popular Front Party, submitted his resignation to the National Council on 6 March. His failure to build an adequate army he could control caused the downfall of his government. Shusha, the last Azerbaijani-inhabited town in Nagorno-Karabakh, came under Armenian control on 6 May. Eight days later, the Supreme Council investigated the Khojaly massacre, absolved Mutallibov of responsibility, overturned his resignation and restored him as president. The following day (15 May), armed Azerbaijan Popular Front forces seized the National Council and the state-owned radio and television stations and deposed Mutallibov, who fled to Moscow. The National Council was dissolved, and the National Assembly (composed of Azerbaijan Popular Front members and former communists) was formed. Two days later (as Armenian forces took Lachin), Isa Gambar was elected National Assembly chair and assumed the duties of the president until national elections scheduled for 17 June 1992.

Elchibey presidency (1992–1993)
The former communists failed to present a viable candidate for the 1992 Azerbaijani presidential election and PFA leader, former dissident and political prisoner Abulfaz Elchibey was elected president with over 60 percent of the vote. Elchibey's program included opposition to Azerbaijan's membership in the Commonwealth of Independent States, closer relations with Turkey, and a desire for improved links with the Iranian Azerbaijanis.

Heydar Aliyev, who had been prevented from running for president by an age limit of 65, was doing well in Nakhchivan but had to contend with an Armenian blockade of the exclave. Azerbaijan halted rail traffic into and out of Armenia, cutting most of its land links with the outside world. The negative economic effects of the Nagorno-Karabakh war on both countries illustrated Transcaucasian interdependence.

Within a year of his election, Elchibey faced the same situation which had led to Mutallibov's downfall. The fighting in Nagorno-Karabakh turned in favour of Armenia, which seized about one-fifth of Azerbaijan's territory and created over one million internally displaced persons. A military rebellion led by Surat Huseynov broke out in early June 1993 in Ganja. The PFA leadership found itself without political support as a result of the war's setbacks, a deteriorating economy, and opposition from groups led by Aliyev. In Baku, he seized power and quickly consolidated his position, and an August vote-of-confidence referendum removed Elchibey from the presidency.

Heydar Aliyev presidency (1993–2003)
A presidential election was held on 3 October 1993, which Heydar Aliyev won overwhelmingly. Aliyev had some of his opposition, including Surat Huseynov, arrested by March 1994. In 1995, the military police were accused of plotting a coup and disbanded; the coup plotters were linked to right-wing Turkish nationalists. The following year, Former National Assembly speaker Rəsul Quliyev went into exile, and Aliyev's position as absolute ruler was unquestionable by the end of 1996.

As a result of limited reforms and the signing of the October 1994 contract for the Azeri–Chirag–Gunashli offshore oilfield complex, which led to increased oil exports to Western markets, the economy began improving. However, extreme levels of corruption and nepotism in Aliyev's government prevented Azerbaijan from more sustained development, however, especially in non-oil sectors.

In October 1998, Aliyev was re-elected to a second term. Although his weakened opposition accused him of voter fraud, there was no widespread international condemnation of the election. Aliyev's second term was characterized by limited reforms, increasing oil production and the dominance of BP as Azerbaijan's main foreign oil company. The Shah Deniz gas field is part of the European Commission's Southern Gas Corridor, and a gas export agreement was signed with Turkey. Work on the Baku-Tbilisi-Ceyhan oil pipeline and the South Caucasus gas pipeline began in 2003; the oil pipeline was completed in 2005, and the gas pipeline in 2006. Azerbaijan was a party to the aborted Nabucco pipeline.

Aliyev's health began to fail. He collapsed during a televised April 2003 speech, and made his son Ilham the unopposed presidential candidate in October. After several months in the Cleveland Clinic with heart and kidney problems, he died on 12 December 2003.

Ilham Aliyev presidency (2003–present)
In another controversial election, Heydar's son Ilham Aliyev was elected president that year. The election, marred by violence, was criticised by foreign observers. Opposition to the Aliyev administration is widespread, with opponents advocating a more democratic government. Aliyev was re-elected in 2008 with 87 percent of the vote, however, as opposition parties boycotted the election. After a 2009 constitutional referendum, presidential term limits were abolished and freedom of the press was restricted.

The 2010 election produced a National Assembly loyal to Aliyev; for the first time in Azerbaijani history, no candidate from the main opposition Azerbaijani Popular Front or Musavat parties was elected. The Economist called Azerbaijan's regime authoritarian, ranking it 135th out of 167 countries in its 2010 Democracy Index.

Demonstrations were held against Aliyev's rule in 2011, calling for democratic reforms and a new government. Aliyev responded with a security crackdown, using force to crush protests in Baku and refusing to make concessions. Over 400 people were arrested during the protests, which began in March. Opposition leaders, including Musavat's Isa Gambar, vowed to continue demonstrating despite police suppression.

On 24 October 2011, Azerbaijan was elected a non-permanent member of the United Nations Security Council. From 1 to 5 April 2016, clashes resumed between Armenian and Azerbaijani armed forces.

In April 2018, President Ilham Aliyev secured his fourth consecutive term in the election that was boycotted by the main opposition parties as fraudulent.

On 27 September 2020, new clashes in the unresolved Nagorno-Karabakh conflict resumed along the Nagorno-Karabakh Line of Contact. Both the armed forces of Azerbaijan and Armenia reported military and civilian casualties. The Nagorno-Karabakh ceasefire agreement and the end of the six-week war between Azerbaijan and Armenia was widely celebrated in Azerbaijan, as they made significant territorial gains.