However, in the 8th century, something happened in Cordoba which was to radically change the course of history in the western world. A contingent of Arabic troops landed on the Mediterranean coast, and easily took over the weakened Visigoth kingdom. Cordoba was captured by Mugit, a deputy of Tariq, and Moslems settled in Cordoba side by side with their Christian counterparts. They lived in harmony, as is proved by the fact that the Moslems actually paid the Visigoths for the rights to move the musalla (the primitive prayer area outside the city walls) to the Visigoth basilica of San Vicente, thus forming the beginnings of the Great Mosque which still survives to this day.
The first rulers of the Islamic Qurtuba made it the administrative centre of their recently conquered lands. However, the fiercely tribal nature of the Arab and Berber peoples soon produced disputes between the rival factions struggling for power.
The arrival of the Omeyan Abd al-Rahman I, known as "the Fugitive" or "the Dispossessed", united all the disaffected groups around the figure of the future Emir. In the year 756 these factions took over Cordoba and proclaimed it capital of the independent Emirate of Al-Andalus. Abd al-Rahman I carried out the first major enlargement of the Great Mosque of Cordoba and rebuilt the city walls and the Alcazar (castle). Hisham I, his son, finished off his father's work in the Great Mosque and built the first minaret, which has not survived. When Abd al-Rahman II came to power, the mosque was enlarged further and a lot of new building went on all over the city.
However, it was in the rule of Abd al-Rahman III when Cordoba really came into the limelight. In the year 929 Cordoba was proclaimed Capital of the independent Caliphate thus creating a schism with Damascus, and converting Cordoba into the religious, political and administrative centre of the entire Islamic kingdom in the west. One of the Caliph's first acts was to build the dazzling, but short-lived, royal residence of Medina Azahara outside the city walls, an endless source of legends due partly to the extravagantly expensive building materials used.
The rule of Alhaken II, son of Abd al-Rahman III, heralded an era of stable government and the period of greatest cultural splendour in Cordoba. The Great Mosque was extended again, this time in the same majestic style as Medina Azahara. His successor, Hixam II, was only a puppet ruler, and left the task of government to his vizier Almanzor, who was responsible for the third and last major enlargement of the mosque.
The joint rule of Almanzor and Hixam weakened the kingdom, and the end was not far in sight. The Caliphate finally collapsed in 1013, and the city became one of the interim Taifa kingdoms.