Prehistory, antiquity and Roman foundation of the city
The first traces of human presence in the area are remains of a Neanderthal Man, dating to c. 42,000 to 35,000 BC. In the 8th century BC, during the ancient Tartessos period, a pre-urban settlement existed. The population gradually learned copper and silver metallurgy. The first historical mention of a settlement dates to the Carthaginian expansion across the Guadalquivir, when general Hamilcar Barca renamed it Kartuba, from Kart-Juba, meaning "the City of Juba", a Numidian commander who had died in a battle nearby. Córdoba was conquered by the Romans in 206 BC.
In 169 Roman consul M. Claudius Marcellus, grandson of Marcus Claudius Marcellus, who had governed both Further and Hither Spain, founded a Latin colony alongside the pre-existing Iberian settlement. Between 143 and 141 BC the town was besieged by Viriatus. A Roman forum is known to have existed in the city in 113 BC. The famous Cordoba Treasure, with mixed local and Roman artistic traditions, was buried in the city at this time; it is now in the British Museum.
It became a colonia with the title Patricia, between 46 and 45 BC. It was sacked by Caesar in 45 due to its Pompeian allegiance, and settled with veterans by Augustus. It became capital of Baetica and had a colonial and provincial forum and many temples. It was the chief center of Roman intellectual life in Hispania Ulterior (Further Spain). Its republican poets were succeeded by Seneca and Lucan.
At the time of Julius Caesar, Córdoba was the capital of the Roman province of Hispania Baetica. The great Roman philosopher Seneca the Younger, his father, the orator Seneca the Elder, and his nephew, the poet Lucan came from Roman Cordoba.
In the late Roman period, its bishop Hosius (Ossius) was the dominant figure of the western Church throughout the earlier 4th cent. Later, it occupied an important place in the Provincia Hispaniae of the Byzantine Empire (552–572) and under the Visigoths, who conquered it in the late 6th century.
Córdoba was captured in 711 by the Umayyad army. Unlike other Iberian towns, no capitulation was signed and the position was taken by storm. Córdoba was in turn governed by direct Umayyad rule. The new Umayyad commanders established themselves within the city and in 716 it became a provincial capital, subordinate to the Caliphate of Damascus; in Arabic it was known as قرطبة (Qurṭuba).
Different areas were allocated for services in the Saint Vincent Church shared by Christians and Muslims, until construction of the Córdoba Mosque started on the same spot under Abd-ar-Rahman I. Abd al-Rahman allowed the Christians to rebuild their ruined churches and purchased the Christian half of the church of St Vincent. In May 766 Córdoba was chosen as the capital of the independent Umayyad emirate, later caliphate, of al-Andalus. By 800 the megacity of Cordoba supported over 200,000 residents, 0.1 per cent of the global population. During the apogee of the caliphate (1000 AD), Córdoba had a population of about 500,000 inhabitants; estimates range from 350,000 to 1,000,000. In the 10th and 11th centuries Córdoba was one of the most advanced cities in the world, and a great cultural, political, financial and economic centre. The Great Mosque of Córdoba dates back to this time. After a change of rulers the situation changed quickly. The vizier al-Mansur–the unofficial ruler of al-Andalus from 976 to 1002—burned most of the books on philosophy to please the Moorish clergy; most of the others were sold off or perished in the civil strife not long after.
In the ninth and tenth centuries, Córdoba was "one of the most important cities in the history of the world." In it, "Christians and Jews were involved in the Royal Court and the intellectual life of the city."
Regarding Córdoba's importance, Reinhardt Dozy wrote:
The fame of Córdoba penetrated even distant Germany: the Saxon nun Hroswitha, famous in the last half of the 10th century for her Latin poems and dramas, called it the "Ornament of the World".
— Reinhardt Dozy
Córdoba had a prosperous economy with its "skilled artisans and agricultural infrastructure," The manufactured goods for sale included "leather and metal work, glazed tiles and textiles." The agricultural produce included fruits, vegetables, spices, herbs, and raw materials such as "cotton, flax and silk."
Córdoba was also famous as a centre of learning. Al-Hakam II had a large library. Knowledge in the fields of "medicine, mathematics, astronomy, botany" exceeded the rest of Europe.
Roger Collins wrote:
The Arab conquest created the conditions for a state of almost permanent warfare in the Iberian Peninsula ... and in scale and intensity exceeded anything to be found elsewhere in Western Europe in these centuries.
In 1002 Al-Mansur was returning to Córdoba from an expedition in the area of Rioja when he died. His death was the beginning of the end of Córdoba. Abd al-Malik al-Muzaffar, al-Mansur's older son, succeeded to his father’s authority, but he died in 1008, possibly assassinated. Sanchuelo, Abd al-Malik’s younger brother succeeded him. While Sanchuelo was away fighting Alfonso V of Leon, a revolution made Mohammed II al-Mahdi the Caliph. Sanchuelo sued for pardon but he was killed when he returned to Cardova. The slaves revolted against Mahdi, killed him in 1009, and replaced him with Hisham II in 1010. Hisham II kept a male harem and was forced out of office. In 1012 the Berbers "sacked Cardova." In 1016 the slaves captured Cardova and searched for Hisham II, but he had escaped to Asia. This event was followed by a fight for power until Hisham III, the last of the Umayyads, was routed from Córdoba in 1031.
After 1031, Córdoba lost its prosperity and fame and became an isolated city. The "ruling elite" were well known for their "disinterest in the outside world ... and intellectual laziness." 
A city map of Córdoba, Andalusia in 1851 (Spanish language edition)
During the process known as the Spanish Reconquista, Córdoba was captured by King Ferdinand III of Castile on 29 June 1236, after a siege of several months. The city was divided into 14 colaciones, and numerous new church buildings were added. The centre of the mosque was converted into a large Catholic cathedral.
The city declined, especially after Renaissance times. In the 18th century it was reduced to just 20,000 inhabitants. The population and economy started to increase again only in the early 20th century.
With the most extensive historical heritages in the world declared World Heritage Site by UNESCO (on 17 December 1984), the city also has a number of modern areas, including the districts of Zoco and the railway station district.
The regional government (the Junta de Andalucía) has for some time been studying the creation of a Córdoba Metropolitan Area that would comprise, in addition to the capital itself, the towns of Villafranca de Córdoba, Obejo, La Carlota, Villaharta, Villaviciosa, Almodóvar del Río and Guadalcázar. The combined population of such an area would be around 351,000. The Plano de Córdoba was also known for its books and how they created it.