Baku is the city with a very ancient and rich history, records of it appears in the V century. At that time, Baku was known as one of the cities of Caucasian Albania. However, its emergence dates back to an earlier time, as were proved by numerous archaeological finds: petroglyphs carved by primitive people on the walls of caves, cliffs and boulders. The oldest rock paintings dates back to Mesolite, however, it is assumed that life existed here even earlier, which makes Gobustan one of the cradles of civilization. In rock carvings the different hunting scenes, ritual and ceremonial processes, ideology, customs and traditions of ancient Azerbaijanis are reflected.
The emergence of the city on the Apsheron peninsula was caused by various factors: favorable geographical position, warm and dry climate, fertile soil, availability of natural resources, as well as its central location at the crossroads of migration and trade routes of the Great Silk Road, stretching from north to south, from west to east. Since the second half of the IX century Baku came under the ownership of Shirvanshahs and became one of the major cities of Shirvan. People were engaged in crafts, trade, fishing, gardening, and petroleum production. In 1191, Shirvanshah Akhsitan I temporarily moved the capital of the state from Shamakha to Baku.
During the Mongol invasion in the XIII century, the town fell into decay. However, in the next century, the economic life of Azerbaijan revived again. The Caspian Sea in some historical sources even mentioned as the Baku Sea. Various goods were exported from Baku to the Golden Horde, the Russian principalities, Iran and Central Asia. In Baku is still preserved historical and architectural monuments - Bukhara caravansary (XIV century)and Multan (Indian) caravansary, indicating trade relations of Baku with these regions. During the reign of Shirvanshakh Halillulaha I (1417-1462) in Baku were made the substantial construction work. Shirvanshahs palace was created in that period.
In 1723, the town was conquered by the troops of Peter I during the Persian campaign, and in 1735 it was returned to Iran. Undoubtedly, numerous wars and feudal strives had a negative effect on the development of Baku, and in the 30-ies of the XVIII century it still was relatively small-sized city. Moreover, trade reduced, and oil production capacity dramatically declined. In 1747, Azerbaijan became the center of Baku Khanate, which existed from 1723. In 1806 during the Russian-Iranian war (1804-1813.) Russian troops occupied the city, and after the end of the war, it joined the Russia Empire. Since 1859, Baku was the center of Baku province.
Under the rule of Russia Empire Baku became one of the industrial and cultural centers of the Caucasus. Industrial production of oil contributed to the development of the city. In 1847 at the Bibi-Eybatskoye field for the first time in the history was mechanically drilled an oil well. In Baku started an influx of foreign capital, Rothschilds and Nobel brothers opened their offices here. In addition to the oil industry here began to develop weaving, numerous mechanical plants were opened, tobacco factories, mills, processing industries, etc.On May 8, 1883, Baku-Tbilisi railway was opened. In the city gathered a lot of immigrants - Russian Jews, Germans, Armenians and Iranian Azerbaijanians, etc.
With the oil boom flourished the cultural life of the city, here were opened numerous theaters, museums, galleries, universities and libraries. Baku became known as Paris of the Caucasus. Tolerance of local people caused a lot of positive feedback. Baku was not dominated by any one culture or religion.
On April 28, 1920, the Red Army entered the capital of Azerbaijan. In Soviet times, Baku became the capital of Azerbaijan Soviet Socialist Republic and one of the administrative, industrial, scientific and cultural centers of the USSR. After the collapse of the USSR, on October 18, 1991, was proclaimed sovereign Republic of Azerbaijan and Baku for the second time in the history of XX century became the capital of an independent state.