بالطب والفلسفة وقرض الشعر ابن رشد الحفيد وابن زهر وأنشأ الأمير يوسف بإشبيلية عمارات فاخرة وأوصل لها مياها غزيرة وبنى جامعا صرف عليه مصاريف طائلة وأنشأ في جميع جهات المملكة مستشفيات وتكايا وحفر آبارا بالصحارى وخانات في الطرق للمسافرين وزاد في مرتبات القضاة والفقهاء للاستعانة وملوك الأندلس صارت عمالا له ثم لما حصل ضعف لهاته الدولة اغتنم العدو الفرصة وصار يقطع كثيرا من المدائن والمعاقل والحصون ويستولي عليها حيث لم يوجد بالأندلس من الجيوش والرجال من يدافع العدو ويقاتله ثم في سنة 626 ه استولى على كورة ماردة وفي سنة 627ه على ميورقة وفي سنة 629ه على جزيرة شقرة وفي سنة 636 ه على قرطبة وعلى شرقي الأندلس شاطبة وغيرها سنة 645 ه وفي السنة قبلها على طرطوشة وما يتبعها من القلاع والحصون وفي السنة بعدها على إشبيلية وبيان الوقائع في أخذها يطول الكلام بذكره وذلك مشتمل على ما تتقرح له الأكباد وتنسجم له العيون ولما أخذت هذه المدائن انحاز المسلمون إلى قطعة من شرقي الأندلس وأول من قام بالأمر في هاته الجهة من بني الأحمر محمد بن نصر وكان أبوه نصر في دولة عبد المؤمن من أمراء الأجناد ومحمد بن نصر هذا يقال له محمد الشيخ وبويع له سنة 629 ه وخطب لأبي زكرياء يحيى بن عبد الواحد الحفصي صاحب تونس ودخل مع ابن الأحمر في تلك البيعة أهل فيان وشريش والطاغية في ذلك الوقت محاصر بلنسية وذلك سنة 636 ه ثم أرسل ابن الأحمر جماعة من أعيان أهل الأندلس منهم ابن عصفور وحبر قضاعة ابن الأبار مستصرخين به يريدون منه النجدة في قتال العدو وعقد أبو زكرياء لتلك البيعة يوما مشهودا وأنشد حبر قضاعة المذكور القصيدة المشهورة التي أولها:
in medicine, philosophy and the composing of poetry Ibn Rushd the grandson and Ibn Zuhr. The emir Yusuf established splendid buildings in Ishbiliya and brought abundant water to them, and built a congregational mosque on which he spent enormous sums. He established in all parts of the kingdom hospitals and hospices, dug wells in the deserts and built inns on the roads for travellers, and increased the salaries of the qadis and jurists for support. The kings of al-Andalus became his governors. Then, when weakness came upon this dynasty, the enemy seized the opportunity and began to cut off many of the cities, strongholds and fortresses and take them, since there were not found in al-Andalus armies and men to repel the enemy and fight him. Then in the year 626 AH he took the district of Marida, in the year 627 AH Mayurqa, in the year 629 AH the island of Shuqr, in the year 636 AH Qurtuba, and in the east of al-Andalus Shatiba and other places in the year 645 AH, and in the year before it Turtusha and the castles and fortresses attached to it, and in the year after it Ishbiliya. The account of the events of their capture would be too long to mention, and it contains what makes livers ulcerate and eyes pour with tears. When these cities were taken, the Muslims withdrew to a part of the east of al-Andalus. The first of the Banu l-Ahmar to take charge of affairs in this region was Muhammad ibn Nasr; his father Nasr was one of the commanders of troops in the dynasty of ʿAbd al-Muʾmin. This Muhammad ibn Nasr is called Muhammad al-Shaykh. Allegiance was given to him in the year 629 AH, and he made the sermon in the name of Abu Zakariyyaʾ Yahya ibn ʿAbd al-Wahid al-Hafsi, lord of Tunis; with Ibn al-Ahmar the people of Fiyan [?] and Sharish entered into that allegiance. The tyrant at that time was besieging Balansiya, and that was in the year 636 AH. Then Ibn al-Ahmar sent a group of the notables of the people of al-Andalus, among them Ibn ʿUsfur and the learned man of Qudaʿa, Ibn al-Abbar, calling on him for help and wanting him to aid them in fighting the enemy. Abu Zakariyyaʾ held a famous day for that allegiance, and the said learned man of Qudaʿa recited the famous ode whose beginning is: