During the first part of this period (1013–1038), the city was ruled by the Arab
Banu Tujib tribe. They were replaced by the Arab
Banu Hud rulers, who had to deal with a complicated alliance with
El Cid of
Valencia and his
Castilian masters against the
Almoravids, who managed to bring the Taifas Emirates under their control. After the death of El Cid, his kingdom was conquered by the Almoravids, and by 1100 they had crossed the Ebro into
Barbastro, which brought them into direct confrontation with
Aragon. The Banu Hud stubbornly resisted the Almoravid dynasty and ruled until they were eventually defeated by the Almoravids in May 1110. The last sultan of the Banu Hud, Abd-al-Malik, and Imad ad-Dawla of Saraqusta, were forced to abandon the capital. Abd-al-Malik allied himself with the Christian Aragonese under
Alfonso I of Aragon and from then on the Muslim soldiers of Saraqusta served in the Aragonese forces. Soon afterwards (1118) a good deal of the old taifa, including the city of Zaragoza, was conquered by the Christian kingdom of Aragon, and remained in Christian hands thereafter. Between c. 1040 and c. 1105, the
Taifa of Lérida was separate from that of Zaragoza. ==List of rulers==