The earliest evidence of human settlement in the territory of Azerbaijan dates to the late Stone Age and is related to the Guruchay culture of the Azykh Cave, where archeological evidences promoted the inclusion of Azerbaijan into the map of the ascent man sites of Europe. The Upper Paleolithic and late Bronze Age cultures are attested in the caves of Tağılar, Damcılı, Zar, Yataq-yeri and in the necropolises of Leylatepe and Saraytepe. The area was conquered by the Achaemenids around 550 B.C.E., leading to the spread of Zoroastrianism.
Later it became part of Alexander the Great's Empire and its successor Seleucid Empire. Caucasian Albanians, the original inhabitants of the area, established an independent kingdom around the fourth century B.C.E.
Early Iranian settlements included the Scythians in the ninth century BC. Following the Scythians, Iranian Medes came to dominate the area to the south of the Aras. The Medes forged a vast empire between 900-700 BC, which was integrated into the Achaemenids Empire around 550 BC.
During this period, Zoroastrianism spread in the Caucasus and Atropatene. Ancient Azaris spoke Ancient Azari language, which belonged to Iranian branch of Indo-European languages.
In 252 C.E., the Sassanids turned it into a vassal state, while King Urnayr officially adopted Christianity as the state religion in the fourth century. Despite numerous conquests by the Sassanids and Byzantines, Albania remained an entity in the region until the ninth century. The Islamic Umayyad Caliphate repulsed both the Sassanids and Byzantines from the region and turned Caucasian Albania into a vassal state after the Christian resistance, led by Prince Javanshir, was suppressed in 667. The power vacuum left by the decline of the Abbasid Caliphate was filled by numerous dynasties such as the Sallarids, Sajids, Shaddadids, Rawadids and Buyids. At the beginning of the eleventh century, the territory was gradually seized by waves of Turkic Oghuz tribes from Central Asia. The first of these Turkic dynasties was the Ghaznavids, which entered the area now known as Azerbaijan by 1030. It is notable that Turkification of Azaris was completed only By the late 1800s. The old Iranic speakers found solely in tiny isolated recesses of the mountains or other remote areas (such as Harzand, Galin Guya, Shahrud villages in Khalkhal and Anarjan). Today, this Turkic speaking population is also known as Azeris.
Locally, the possessions of the subsequent Seljuq Empire were ruled by atabegs, who were technically vassals of the Seljuq sultans, being sometimes de facto rulers themselves. Under the Seljuq Turks, local poets such as Nizami Ganjavi and Khagani Shirvani gave rise to a blossoming of Persian literature on the territory of present-day Azerbaijan. The next ruling state of the Jalayirids was short-lived and fell under the conquests of Timur. The local dynasty of Shirvanshahs became a vassal state of Timur's Empire and assisted him in his war with the ruler of the Golden Horde Tokhtamysh. Following Timur's death two independent and rival states emerged: Kara Koyunlu and Ak Koyunlu. The Shirvanshahs returned, maintaining a high degree of autonomy as local rulers and vassals from 861 until 1539. During their persecution by the Safavids, the last dynasty imposed Shia Islam upon the formerly Sunni population, as it was battling against the Sunni Ottoman Empire.
After the Safavids, the area was ruled by the Iranian dynasties of Afshar and Zand and briefly by the Qajars. However, while under Persian sovereignty de facto self-ruling khanates emerged in the area, especially following the collapse of the Zand dynasty and in the early Qajar era. The brief and successful Russian campaign of 1812 was concluded with the Treaty of Gulistan, in which the shah's claims to some of the Khanates of the Caucasus were dismissed by Russia on the ground that they had been de facto independent long before their Russian occupation. The khanates exercised control over their affairs via international trade route between Central Asia and the West. Engaged in constant warfare, these khanates were eventually incorporated into the Russian Empire in 1813, following two Russo-Persian Wars. The area to the North of the river Arax, amongst which the territory of the contemporary republic of Azerbaijan were Iranian territory until they were occupied by Russia.
Under the Treaty of Turkmenchay, Persia recognized Russian sovereignty over the Erivan khanate, the Nakhchivan khanate and the remainder of the Talysh Khanate.
Azerbaijan Democratic Republic
After the collapse of the Russian Empire during World War I, Azerbaijan, together with Armenia and Georgia became part of the short-lived Transcaucasian Democratic Federative Republic. When the republic dissolved in May 1918, Azerbaijan declared independence as the Azerbaijan Democratic Republic (ADR). The ADR was the first democratic parliamentary republic in the Muslim World.
Among the important accomplishments of the Parliament was the extension of suffrage to women, making Azerbaijan the first Muslim nation to grant women equal political rights with men. In this accomplishment, Azerbaijan also preceded the United Kingdom and the United States. Another important accomplishment of ADR was the establishment of Baku State University, which was the first modern-type university founded in Muslim East.
By March 1920, it was obvious that Soviet Russia would attack the much-needed Baku. Vladimir Lenin said that the invasion was justified by the fact that Soviet Russia could not survive without Baku oil. Independent Azerbajian lasted only 23 months until the Bolshevik XIth Red Army invaded it and establishing the Azerbaijan SSR on April 28, 1920.
Although the bulk of the newly formed Azerbaijani army was engaged in putting down an Armenian revolt that had just broken out in Karabakh, but Azeris did not surrender their brief independence of 1918-20 quickly or easily. As many as 20,000 Azerbaijani soldiers died resisting what was effectively a Russian reconquest.
Despite existing for only two short years, the multi party Azerbaijani Parliamentary republic and the coalition governments managed to achieve a number of measures on national and state building, education, creation of an army, independent financial and economic systems, international recognition of the ADR as a de facto state pending de jure recognition, official recognitions and diplomatic relations with a number of states, preparing of a Constitution, equal rights for all, etc. This has laid an important foundation for the re-establishment of independence in 1991.
In October 13, 1921, the Soviet republics of Russia, Armenia, Azerbaijan, and Georgia signed an agreement with Turkey known as the Treaty of Kars. The previously independent Naxicivan SSR would also become autonomous ASSR within Azerbaijan by the treaty of Kars. On the other hand, Armenia was awarded the region of Zhangezur and Turkey agreed to return Alexandropol (Gymri).
In March 12, 1922, under heavy pressure from Moscow, the leaders of Azerbaijan, Armenian, and Georgian Soviet Socialist Republics established a union known as the Transcaucasian SFSR. This was the first attempt at a union of Soviet republics, preceding the USSR. The Union Council of TSFSR consisted of the representatives of the three republics - Nariman Narimanov (Azerbaijan), Polikarp Mdivani (Georgia), and Aleksandr Fyodorovich Miasnikyan (Armenia). The First Secretary of the Transcaucasian Communist Party was Sergo Ordzhonikidze. In 1936, TSFSR was dissolved and Azerbaijan SSR became one of the constituent member states of the Soviet Union.
During World War II, Azerbaijan played a crucial role in the strategic energy policy of Soviet Union, much of the Soviet Union's oil on the Eastern Front was supplied by Baku. By the Decree of the Supreme Soviet of the USSR in February 1942, the commitment of more than 500 workers and employees of the oil industry of Azerbaijan was awarded orders and medals. Operation Edelweiss carried out by the German Wehrmacht targeted Baku because of its importance as the energy (petroleum) dynamo of the USSR. Some 800,000 Azerbaijanis fought well in the ranks of the Soviet Army of which 400,000 died and Azeri Major-General Azi Aslanov was awarded twice Hero of the Soviet Union.
Restoration of independence
Following the politics of glasnost, initiated by Mikhail Gorbachev, civil unrest and ethnic strife grew in various regions of the Soviet Union, including Nagorno-Karabakh, a region of the Azerbaijan SSR. The disturbances in Azerbaijan, in response to Moscow's indifference to already heated conflict, resulted in calls for independence and secession, which subsequently culminated in the events of Black January in Baku. At this time, Ayaz Mütallibov was appointed as the First Secretary of the Azerbaijan Communist Party. Later in 1990, the Supreme Council of the Azerbaijan SSR dropped the words "Soviet Socialist" from the title, adopted the Declaration of Sovereignty of the Azerbaijan Republic and restored the modified flag of the Azerbaijan Democratic Republic as a state flag. On 8 September 1991, Ayaz Mütallibov was elected president in nationwide elections in which he was the only candidate.
On 18 October 1991, the Supreme Council of Azerbaijan adopted a Declaration of Independence which was affirmed by a nationwide referendum in December 1991, when the Soviet Union was officially dissolved. The early years of independence were overshadowed by the Nagorno-Karabakh War with neighboring Armenia. By the end of hostilities in 1994, Azerbaijan lost control of up to 16% of its territory, including Nagorno-Karabakh itself. An estimated 30,000 people had been killed and more than a million had been displaced. Four United Nations Security Council Resolutions (822, 853, 874, and 884) called for "the withdrawal of occupying forces from occupied areas of the Azerbaijani Republic". In 1993, democratically elected president Abülfaz Elçibay was overthrown by a military insurrection led by Colonel Surat Huseynov, which resulted in the rise to power of the former leader of Soviet Azerbaijan, Heydar Aliyev. In 1994, Surat Huseynov, by that time a prime minister, attempted another military coup against Heydar Aliyev, but Huseynov was arrested and charged with treason. In 1995, another coup attempt against Aliyev, by the commander of the military police, Rovshan Javadov, was averted, resulting in the killing of the latter and disbanding of Azerbaijan's military police.
Although during his presidency Aliyev managed to reduce the country's unemployment, reined in criminal groups, established the fundamental institutions of independent statehood, and brought stability, peace and major foreign investment, the country was tainted by rampant corruption in the governing bureaucracy. In October 1998, Aliyev was reelected for a second term. Despite the much improved economy, particularly with the exploitations of Azeri-Chirag-Guneshli oil field and Shah Deniz gas field, Aliyev's presidency became unpopular due to vote fraud, widespread corruption and objection to his autocratic regime. The same harsh criticism followed the elections of former Prime Minister Ilham Aliyev, the second leader of New Azerbaijan Party after the death of his father Heydar.