"During the 10th century, al-Andalus reached the pinnacle of its power, with its influence stretching from the Pyrenees well into North Africa. When the powerful caliph, Abd al-Rahman III, died in 961 the Umayyad dynasty seemed more entrenched than ever, but amazingly within 70 years the caliphate was in ruins. But at least it did not go out without a kind of bang, the fireworks being provided in the last years of the century by the powerful vizier, Muhammad ibn Abu ‘Amir, de facto ruler during most of the reign of Abd al-Rahman's weak grandson, Hisham II (ruled 976-1009, 1010-1013).
Abu ‘Amir, better known by his honorific title, al-Mansur (meaning "the Victorious." Almanzor in Spanish) was a noble of Arab background from near Algeciras. He manoeuvred his way into power when befriended by Hisham's mother, a Christian captive from Navarre (who allegedly became his lover as well). Al-Mansur is best remembered for the numerous, devastating raids (razzias) - some 57 in all - directed against the Christian north. He swept across Christian lands, from Barcelona (985) to Coimbra (987); he attacked Leon and Zamora (988), and numerous smaller places. The high point was the raid on Santiago de Compostela (Galicia) in 997, in which the town was razed, the church destroyed and its bells taken to Córdoba –on the backs of prisoners-of-war-- to be used as lamps in the Great Mosque. All that remained apparently was the tomb of Santiago which, we are told, was spared because it was a holy place, and because al-Mansur was impressed by the courage of an old priest who refused to abandon it.
In order to improve the efficiency of his forces for the razzias, al-Mansur reorganised his armies in 991, and eliminated regiments made up of tribal groups. He also recruited mercenaries, especially Berbers from the Maghreb --and even Christian soldiers-- to provide the manpower that the raids required.
In many ways, the actions of al-Mansur were a challenge to the Umayyad caliphate and an attempt to establish his own personality on Córdoba: he was more pious than the caliph (ostensibly the successor to the Prophet, Muhammad), he burned secular books from al-Hakam’s magnificent libraries, and he undertook more razzias than Abd al-Rahman III. And in adding to the Great Mosque and building his own palace complex, al-Mansur signalled his power and authority in much the same way the palace of Madinat al-Zahra conveyed the greatness of Abd al-Rahman III. The eight-aisled extension at the east end of the Mosque is remarkably restrained, but it underlines al-Mansur’s piety, especially when compared to the luxurious addition of al-Hakam II (ruled 961-76). As for the palace, whose name–Madinat al-Zahira— implicitly challenges that of Abd al-Rahman III’s Madinat al-Zahra, it has never been found. All we know is that it was built somewhere on the other side of Córdoba from Madinat al-Zahra!
Nevertheless, al-Mansur was not above coming to terms with his Christian enemies if it served his personal ambitions. Having usurped power from the Umayyads, he sought to legitimize his dynastic aims through marriage to royalty, in this case with a Christian princess. In 992, he married the daughter of the king of Navarre, who bore him a son pointedly named Abd al-Rahman, but equally or better known as Sanjul or Sanchuelo (after his maternal grandafther, Sancho, king of Pamplona). Al-Mansur's death in 1002 when returning from a successful expedition in the Rioja area effectively marks the end of Córdoba.
Source - Spain, Then and now:10th C. Al-Andalus: Al-Mansur