Abd al-Rahman I began the congregational mosque of Cordoba in 785, on ground that had held a Visigothic church; later Muslim writers say the site was first shared and then bought outright, an account that comes from centuries afterwards and cannot be checked. The builders reused Roman and Visigothic columns, which came in different heights, and solved the problem by stacking two tiers of arches in alternating brick and stone, producing the forest of red and white horseshoes that the building is known for. Three later rulers extended it, and al-Hakam II added a prayer niche whose gold ground mosaics were made by craftsmen sent, according to the chronicles, by the Byzantine emperor.
The caliphate declared at Cordoba in 929 gave al-Andalus a ruler claiming the title in his own right, in competition with Baghdad and with the Fatimids, and the mosque was the architectural statement of that claim.
Ferdinand III took the city in 1236 and the mosque became a cathedral, which is why it survived when so much else did not. In the 1520s the chapter cut a Renaissance nave and choir through the middle of the hall, over the objection of the city council; the emperor Charles V, who had approved the work, is reported to have said on seeing it that they had built what could be built anywhere and destroyed what was unique in the world. The building is a working cathedral today, and Muslim requests to be allowed to pray in it, along with arguments about what it should be called, have been refused and remain live.