Spain experienced a great flowering under the Omayyad Dynasty (755 - 1031).
The most important ruler was
Abd Ar-Rahman III (921-61) who claimed the Caliphate in 929.
But after 1008 conflicts over the succession to the throne led to a civil war
and the dissolution of the Omayyad Caliphate.
After the king of Castille initiated the Christian offensive (Reconquista) the Berber Almoravids were
summoned for help. In 1085 El Cid conquered Toledo and made himself master of Valencia.
In 1118 Alfonso of Aragon conquered Saragossa.
Later Ferdinand III of Castile conquered the South, incl. Cordoba (1236), and completed the Reconquista.
After the union of Castile and Aragon
the last remnant of Moorish power, the Emirate of Granada, was eliminated in 1492.