The Almoravid ruler Yūsuf ibn Tāshufīn entered the Iberian Peninsula from North Africa and slowly advanced to the fields of Al-Zallāqah, north of Badajoz (Baṭalyaws), where in 1086 he defeated a Castilian army under Alfonso VI. However, unable to further exploit his victory, he returned to the Maghrib. For two years Almoravid policy in Spain remained indecisive, but it appears that the siege of Aledo (1088) convinced Yūsuf ibn Tāshufīn of the urgent necessity of putting an end to the ṭāʾifas if he was going to rescue Spanish Islam. From 1090 he deposed their rulers, beginning with those of Granada and Málaga; the next year he dethroned the rulers of Almería and Sevilla, followed by the leader of Badajoz in 1093. Only Rodrigo Díaz de Vivar (the Cid), exiled from his native Castile by King Alfonso VI, was able to resist the Africans, and he established an independent kingdom in Valencia—a new ṭāʾifa. The figure of the Cid—the Lord (Spanish Arabic: al-sīd), a title that the Arabs conferred upon him—is quite curious. He first served as a mercenary in the ṭāʾifa of Zaragoza, after which he became an independent prince in the east, ruling over states that were mainly inhabited by Muslims. He had the good fortune, however, of finding efficient administrators from among the Mozarabs residing in his states; further, his superb grasp of Almoravid tactics enabled him to overcome his numerical inferiority. Upon his death, Valencia remained under the control of his forces until 1102, when they were forced to evacuate it and seek refuge in Castile. Following the fall of Valencia, the Almoravids were unopposed, and in 1110, under the leadership of ʿAlī ibn Yūsuf (1106–43), they were able to occupy Zaragoza.
Alfonso VI, portrait miniature from a manuscript, 12th century; in Santiago cathedral, Spain.Archivo Mas, Barcelona
However, the conquest of Zaragoza marked the beginning of the Almoravid decline. The Aragonese king, Alfonso I (the Battler), and his stepson, Alfonso VII of Castile, launched renewed Christian assaults against the entire frontier of Islam in Spain. In 1118 Zaragoza fell into the hands of Alfonso I, who reconquered a large part of the valleys of the Jalón and of the Jiloca. After 1121 the Almoravids experienced serious difficulties in Africa as a result of the preachings of an Amazigh reformer, Muḥammad ibn Tūmart, and could not successfully withstand the Christian onslaught; indeed, they had to hire Christian mercenaries to help them. A resounding Almoravid victory over the Aragonese at Fraga (Ifragah) in 1134 bore no fruit, because the Almoravids lacked the resources to exploit it. The Almohads
In Africa the Almohad dynasty finally triumphed, and ʿAbd al-Muʾmin (1130–63), successor to Ibn Tūmart, turned his attention to Spain and to the integration of all the Muslim states—the second ṭāʾifas—formed under the shield of the latest internecine wars caused by the Almoravid decline. Of these states, those under Ibn Mardanīsh (1147–72)—who was successful with Christian help in becoming the master of Valencia, Murcia, and Jaén and in securing Granada and Córdoba—especially stood out.
The Almohads assumed the title of caliph, introduced a series of severe religious measures, and sought to strengthen their states through religious unification—i.e., by compelling the Jews and Christians to either convert to Islam or emigrate. Two great sovereigns, Abū Yaʿqūb Yūsuf (1163–84) and Abū Yūsuf Yaʿqūb al-Manṣūr (1184–99), raised western Islam to the zenith of its power. Benefiting from the quarrels that divided the Christians, al-Manṣūr defeated the king of Castile, Alfonso VIII, in 1195 at the Battle of Alarcos (Al-Arak); despite this victory, however, he proved unable to exploit his triumph—repeating the fate that had befallen the Almoravids after al-Zallāqah. Years later, during the reign of his successor Muḥammad al-Naṣīr (1199–1214), the Christians avenged this defeat in the Battle of Las Navas de Tolosa (Al-ʿIqāb). This battle created a power vacuum into which stepped some of the ṭāʾifas, prominent among which were those of Banū Hūd of Murcia (Mursīyah) and of the Naṣrids of Arjona (Arjūnah). The policies of the two emirs were quite divergent: Muḥammad ibn Hūd (1228–38) emphasized resistance on the part of the Muslims against the Christians who, led by Ferdinand III, were occupying the Guadalquivir valley; by contrast, Muḥammad I ibn al-Aḥmar (ruled in Granada 1238–73) acknowledged himself to be a vassal of the king of Castile and even helped him against his own Muslim coreligionists. This realistic policy enabled him to preserve in his possession the territory of what are the modern provinces of Málaga, Granada, and Almería, together with portions of neighbouring provinces. Thus, after the middle of the 13th century and the reconquest of Jaén (Jayyān), Córdoba, Sevilla, and Murcia by the Castilians and of Valencia and the Balearic Islands by the Catalan-Aragonese crown under James I (the Conqueror), no independent dominions of Islam remained in Spain—with the exception of Granada, Minorca (until 1287), and the tiny area of Crevillente (Qirbilyān), which soon disappeared. Granada
The Naṣrid dynasty, founded by Muḥammad ibn al-Aḥmar in Granada, endured for two and a half centuries. The Muslims of Granada lacked sufficient forces to constitute a genuine danger to the Christians, who limited themselves to collecting tribute and launching an attack against the Muslims from time to time, snatching from them some city or other. The people of Granada, for their part, always bore in mind what had happened in the cases of the Almoravids and the Almohads, who, having arrived from Africa as auxiliary troops, became masters in Al-Andalus. Vis-à-vis the new North African empires, particularly the empire of the Banū Marīns, they maintained a policy of balance of power. Although they permitted the influx of volunteers from Africa to enroll in their army to fight against the Christians, they never permitted the crossing of the Strait of Gibraltar by massive organized contingents. The years between 1302 and 1340 were extraordinarily complex both diplomatically and militarily. The Banū Marīns in both the western Maghrib and Castile vied for the possession of the Granadan ports of Tarifa (Jazīrat Ṭarīf) and Algeciras (Al-Jazīrah al-Khaḍraʾ), ports that controlled the strait. Granada, therefore, allied alternately with the Africans and the Christians, hoping thus to maintain the balance of power. A fourth state, Catalonia, called a Crusade; hoping to obtain a larger slice of the Reconquista, it intervened with its fleet and laid siege to Almería (Al-Marīyah) in 1309.
When Ismāʿīl I (1314–25) ascended the throne, another branch of the Naṣrid family gained power. Ismāʿīl checked the reconquest ambitions of Alfonso XI—who in 1340, with the aid of the Portuguese, won a decisive victory over the Maghribian army of Abū al-Ḥasan at the Battle of the Salado. The defeat of the Maghribians and the lack of interest in reconquest on the part of Alfonso’s successors created a favourable climate for Granada, which found itself free from political pressures of both Maghribians and Castilians. During the reign of Muḥammad V (1354–59; 1362–91) Granada attained its greatest splendour; its ministers included some of the most learned men of the epoch, such as the polymath Abū ʿAbd Allāh ibn al-Khaṭīb, the physician Abū Jaʿfar ibn Khātima, and the poet Abū ʿAbd Allāh ibn Zamraq. Important figures from the Maghrib were in close touch with Granada.