Al-Hakam II
In the early part of his reign, Caliph Al-Hakam II successfully waged war against the Christian kings, Sancho I of León and Castile and García of Navarre. His naval forces defeated Norman sea raiders and seized Tangier from the Idrisids, thereby annexing Morocco to the Caliphate. The Fatimids were defeated in Morocco in 974. The Idrisids were expelled from their territories and Al-Hasan ibn al-Qasim Jannun (the last Idrisid ruler), along with many other Idrisids or their sons, were taken as hostages to Córdoba.