The territory of present-day Azerbaijan has been continuously inhabited since the Paleolithic era. The first evidence of tribal alliances date to the first millenium BC , when such peoples as the Mannaians, the Medes, the Cadusiis, the Albanoi, and the Caspians appeared. In the 7th century BC , the state of Media appeared in what now is southern Azerbaijan, growing to cover large portions of the Near East. The Medians were displaced by the Persian dynasty of Achaemenids, who in turn were defeated by Alexander the Great. In the 4th century BC , another state arose which Greek sources called Atropatena, or "Land of the Fire Keepers"; it is this name, reflecting the predominance of Zoroastrianism, which may have given the present state its name. Around the beginning of the common era Atropatena was succeeded by a state called Albania, which the Romans attempted to conquer.
In the 3rd and 4th centuries AD , Azerbaijan existed with fluid boundaries between the Sassanid state in Persia and the Romans, whose battles inflicted great damage, leaving Azerbaijan open to raids by Turkic nomadic tribes from the north, including Khazars and Huns. Outside influence reappeared in the 7th and 8th centuries, when Arabs conquered much of Transcaucasia. As their influence receded, a number of small local states were established, the best known of which was the Shirvanshahs.
In the 11th century Azerbaijan was invaded by Oguz Turks, of the Seljuk dynasty. By the 13th century the gradual displacement of pre-Turkic local languages was complete, although many traces of non-Turkic predecessors remain in the Azerbaijani language. Persian, however, remained the language of art, science, and education.
In the 1230s Azerbaijan was conquered by Genghiz Khan, whose power remained in the Il-Khanid state, which at the end of the 14th century was displaced by the armies of Tamerlaine. In the 16th century, the Safawid state emerged, coming to control most of the land between the Syr Darya and the Euphrates, and reestablishing agriculture and commerce destroyed under the Mongols. In the 17th century, the Safawids became Persianized, which made present-day Azerbaijan decline in importance.
In the 18th century Azerbaijan became the intersection of the Turkish, Persian, and Russian empires, as well as the focus of British and French attempts to block Russian expansion. The northern part of the territory was incorporated into Russia in the first third of the 19th century, but the area did not become important until the 1880s, when the area's abundant oil gained commercial importance. The southern portion of what was originally Azerbaijan has remained in Iran, except for the period 1941–46, when it was occupied by Soviet troops.
When the 1917 Russian revolution came, Ottoman Turkish troops moved into Azerbaijan, and later British forces controlled the capital, Baku. The Azerbaijani Musavat, or Equality Party, established a government, declared Azerbaijan's independence,
and received diplomatic recognition from several states. Azerbaijan was invaded by the Russian Bolsheviks' Red Army in April 1920, and Azerbaijan was declared a Soviet state. In 1922 it was made part of the Transcaucasian Federated Socialist Republic, along with Georgia and Armenia. That was dissolved in 1936, when the three states were each made into separate Soviet Socialist Republics.
In 1988, calls by ethnic Armenians living in Azerbaijan's Nagorno Karabakh (NK) region to be incorporated into the Armenian republic led to open conflict which lasted until 1994. This predominantly Armenian area had been unsuccessfully claimed by the Armenians in the 1920s, at the time of the creation of Soviet Azerbaijan. Inability to solve the NK conflict was one of the problems which ultimately brought down Mikhail Gorbachev and broke apart the USSR. Ethnic and civil violence in January 1990 prompted the occupation of Baku by Soviet armed forces and Moscow's replacement of Abdulrakhman Vezirov with Ayaz Mutalibov as republic head. During this period of martial law, the legislature elected Mutalibov as president in May 1990. Independence was declared on 30 August 1991, and Mutalibov was reaffirmed as president in a popular, uncontested election in September 1991.
In December 1991, NK's Armenians held a referendum (boycotted by local Azerbaijanis) that approved NK's independence and elected a Supreme Soviet, which on 6 January 1992, declared NK's independence and futilely appealed for world recognition. Following a late February 1992 massacre of Azerbaijani civilians in the town of Khojaly in NK, Mutalibov was accused of failing to protect Azeri citizens and forced by the nationalist oppositionist Azerbaijani Popular Front (APF) and others to resign as president. His replacement, legislative head Yakub Mamedov, was also forced to resign in May 1992, in the face of further Azerbaijani military defeats in NK. Mutalibov was then reinstated by loyalists in the Supreme Soviet, but he had to flee two days later, when the APF seized power. Former Soviet dissident and APF leader Abulfaz Elchibey, was elected president in a popular contest in June 1992.
The nationalist government took several moves to cut its ties to Russia, including demanding the withdrawal of Russian troops, refusing to participate as a member of the Commonwealth of Independent States, negotiating with Western firms to develop its oil resources, and improving relations with Turkey. However, military losses in NK increased. In 1993, Heydar Aliyev, who had been the Communist Party leader of the republic from 1971–85 but then was ousted and disgraced by Soviet leader Mikhail Gorbachev, began to press for Elchibey's dismissal.
An abortive attempt by the Elchibey government in June 1993 to disarm paramilitary forces in the town of Ganja precipitated the fall of the government and provided the opportunity for Aliyev to regain power. These forces were led by Suret Huseynov, formerly in charge of troops in NK, who had been fired by Elchibey. Huseynov's forces, supplied with Russian equipment, defeated an Azerbaijani Army attack and began to march on Baku. His government in chaos, Elchibey invited Aliyev to come to Baku, and on 15 June, he endorsed Aliyev's election by the legislature as its new speaker. Elchibey fled to the Nakhchiveni Autonomous Republic (NAR) on 17 June. On 24 June 1993, a bare quorum of legislators met and formally stripped Elchibey of presidential powers, transferring them to Aliyev. Huseynov demanded and was given the post of prime minister.
On 3 October 1993, Aliyev was elected president with 98.8% of the vote. The referendum and election were viewed as not "free and fair" by many international observers because of suppression of APF and other opposition participation. In late September 1994, police and others in Baku launched a purported coup attempt. Aliyev darkly hinted at Russian involvement. After defeating the coup attempt, Aliyev also accused Prime Minister Huseynov of major involvement, and Huseynov fled the country. Other coup attempts were reported in 1995 and 1999. All of the alleged coup attempts triggered mass arrests of Aliyev's opponents.
On 11 October 1998, incumbent President Aliyev defeated five other candidates and was elected to a second five-year term, receiving over 76% of 4.3 million votes cast. The major "constructive opposition" candidate running was Etibar Mamedov of the National Independence Party (NIP), who received 11.6% of the vote. Most international observers judged the vote not "free and fair," citing myriad irregularities, though also noting that the election marked some improvement in political pluralism.
The conflict with Armenian separatists over its Nagorno-Karabakh region continues to plague Azerbaijan. Azerbaijan asserts that NK forces occupy over 20% of Azerbaijan's territory both in and around NK. The conflict has resulted in about 30,000 casualties on both sides and over 840,000 Azerbaijani refugees and displaced persons (and over 300,000 Armenians). The Organization for Security and Cooperation in Europe (OSCE) began the "Minsk Group" peace talks in June 1992. A Russian-mediated cease-fire was agreed to in May 1994 and was formalized by an armistice signed by the ministers of defense of Armenia and Azerbaijan and the commander of the NK army on 27 July 1994 (and reaffirmed a month later). Moscow talks were held by the sides, with token representation by the OSCE, along with Minsk Group talks. With strong US backing, the OSCE at its Budapest meeting agreed in December 1994 to send OSCE peacekeepers to the region under UN aegis if a political settlement could be reached. Russia and the OSCE assented to merge their mediation efforts. France was nominated as a cochair in 1996. This elicited criticism from Azerbaijan that the French had appeared pro-Armenian, leading to the seating of US, French, and Russian cochairs. (Many Azerbaijanis also have voiced reservations about Russia's objectivity as a mediator, citing its defense ties to Armenia.) Direct Armenian-Azerbaijani contacts by the presidents and advisors have also occurred.
Prospects for a negotiated settlement remain elusive because the sides remain far apart on most substantive issues such as the placement and composition of a peacekeeping force and NK's ultimate political status. Personal meetings by the two presidents raised hopes that a statement of intention could be issued at the November 1999 OSCE Summit, but events such as resignations of some Azerbaijani officials apparently opposed to NK proposals, Aliyev's infirmity, and October 1999 assassinations in Armenia (apparently unrelated to the NK talks) appeared to set back progress.
Peace talks between Armenia and Azerbaijan were held in Paris and Florida in 2001, but by December 2002, Lieutenant General Seyran Ohanian, commander-in-chief of the armed forces of NK, warned Azerbaijan that the enclave's army was "better prepared than ever before" and "ready to repulse the enemy" and carry out a successful counteroffensive should conflict begin. President Aliyev in September 2002 told representatives of the Minsk Group that "the people's mood is changing. They are starting to lose hope in a peaceful solution and are coming to the view that we have to recover our land ourselves by whatever means necessary….It has been…nearly ten years since the Minsk Groupwas created. How much longer can we go on talking about a peace settlement?"
In 2001, the United States lifted a ban on aid imposed during the NK conflict after Azerbaijan provided airspace and intelligence to the United States following the 11 September 2001 terrorist attacks.
In September 2002, construction began on a multibillion-dollar pipeline to carry Caspian oil from Azerbaijan to Turkey via Georgia. The government held a referendum on 24 August 2002 to approve 39 changes to the constitution. Some of the major articles at issue were the abolishment of the proportional system of election of deputies to the national parliament; making the prime minister, not the speaker of the parliament, a caretaker president in case the president is not able to carry out his duties; and giving lower level courts the right to ban political parties. Opposition leaders argued that abolishment of the proportional system would damage the multi-party system in the country and further strengthen the ruling elite. In addition to this, the opposition claimed that President Aliyev intended to appoint his son Ilham prime minister and then retire, thus paving the way for his son to become the next president. President Aliyev also approved adding a provision to the Law on State Secrets, which would make editors and journalists of local mass media accountable for disseminating state secrets. The government claimed that there was nearly 100% support for the constitutional changes with 88% voter turnout, while opposition groups stated turnout was closer to 15%, which would render the vote invalid. Demonstrators called for the resignation of President Aliyev and for holding free and fair elections. Supporters of more than 30 opposition parties, including the major parties Musavat, the Popular Front, the Azerbaijan Democratic Party and the Azerbaijan National Independence Party, held marches on 14 September 2002 urging the authorities to cancel the results of the referendum. On 27 October and again on 24 November of that year, the opposition parties marched again under the banner of the United Opposition Movement, claiming that over 50,000 people participated in the marches.