Under the late Córdoban caliphate, Lérida was ruled by "wālī"s of the Banū Tudjīb. In 1039, it was taken from them, along with Zaragoza, by al-Mustaʿīn of the Banū Hūd. At some point prior to his death in 1046, al-Mustaʿīn placed his younger son, Yūsuf ibn Sulaymān ibn Hūd al-Muẓaffar, in charge of Lérida, while in 1046 the elder son, Aḥmad al-Muḳtadir, inherited Zaragoza. From 1045, Count Ramon Berenguer I of Barcelona forced the brothers to pay tribute ("parias") in return for his not attacking them. In 1064, the brothers had a falling out over the loss of Barbastro to an international Christian army, for which defeat al-Muḳtadir blamed Yūsuf, although the city was soon recovered.