Almoravid dynasty
Decline

Almoravid fortunes began to turn definitively after 1117. While Léon and Castile were in disarray following the death of Alfonso VI, other Christian kingdoms exploited opportunities to expand their territories at the expense of the Almoravids. In 1118, Alfonso I El Batallador ('The Battler'), king of Aragon, launched a successful attack on Zaragoza with the help of the French crusader Gaston de Béarn. The siege of the city began on 22 May and, after no significant reinforcements arrived, it surrendered on 18 December. Ali ibn Yusuf ordered a major expedition to recover the loss, but it suffered a serious defeat at the Battle of Cutanda in 1120.

The crisis is evidence that Almoravid forces were over-extended across their vast territories. When the Almoravid governor of Zaragoza, Abd Allah ibn Mazdali, had died earlier in 1118, no replacement was forthcoming and the Almoravid garrison left in the city prior to the siege seems to have been very small. It is possible that Yusuf ibn Tashfin had understood this problem and had intended to leave Zaragoza as a buffer state between the Almoravids and the Christians, as suggested by an apocryphal story in the Hulul al-Mawshiya, a 14th-century chronicle, which reports that Ibn Tashfin, while on his deathbed, advised his son to follow this policy. Alfonso I's capture of Zaragoza in 1118, along with the union of Aragon with the counties of Catalonia in 1137, also transformed the Kingdom of Aragon into a major Christian power in the region. To the west, Afonso I of Portugal asserted his independent authority and effectively created the Kingdom of Portugal. The growing power of these kingdoms added to the political difficulties Muslims now faced in the Iberian Peninsula.

This major reversal precipitated a decline in popular support for the Almoravids, at least in al-Andalus. The Andalusi society largely cooperated with the Almoravids on the understanding that they could keep the aggressive Christian kingdoms at bay; once this was no longer the case, their authority became increasingly hollow. Their legitimacy was further undermined by the issue of taxation. One of the main appeals of early Almoravid rule had been its mission to eliminate non-canonical taxes (i.e. those not sanctioned by the Qur'an), thus relieving the people of a major fiscal burden. However, it was not feasible to finance Almoravid armies in the fight against multiple enemies across a large empire with the funding from Quranic taxes alone. Ali ibn Yusuf was thus forced to reintroduce non-canonical taxes while the Almoravids were losing ground.

These developments may have been factors in sparking an uprising in Cordoba in 1121. The Almoravid governor was besieged in his palace and the rebellion became so serious that Ali ibn Yusuf crossed over into al-Andalus to deal with it himself. His army besieged Cordoba but, eventually, a peace was negotiated between the Almoravid governor and the population. This was the last time Ali ibn Yusuf visited al-Andalus.

Alfonso I of Aragon inflicted further humiliations upon the Almoravids in the 1120s. In 1125, he marched down the eastern coast, reached Granada (though he refrained from besieging it), and devastated the countryside around Cordoba. In 1129, he raided the region of Valencia and defeated an army sent to stop him. The Almoravid position in al-Andalus was only shored up in the 1130s. In 1129, following Alfonso I's attacks, Ali ibn Yusuf sent his son (and later successor), Tashfin ibn Ali, to re-organize the military structure in al-Andalus. His governorship grew to include Granada, Almeria, and Cordoba, becoming in effect the governor of al-Andalus for many years, where he performed capably. The Banu Ghaniya clan, relatives of the ruling Almoravid dynasty, also became important players during this period. Yahya ibn Ali ibn Ghaniya was governor of Murcia up to 1133, while his brother was governor of the Balearic Islands after 1126. For much of the 1130s, Tashfin and Yahya led the Almoravid forces to a number of victories over Christian forces and reconquered some towns. The most significant was the Battle of Fraga in 1134, where the Almoravids, led by Yahya, defeated an Aragonese army besieging the small Muslim town of Fraga. Notably, Alfonso I El Batallor was wounded and died shortly after.

The greatest challenge to Almoravid authority came from the Maghreb, in the form of the Almohad movement. The movement was founded by Ibn Tumart in the 1120s and then continued after his death (c. 1130) under his successor, Abd al-Mu'min. They established their base at Tinmal, in the High Atlas mountains south of Marrakesh, and from here they progressively rolled back Almoravid territories. The struggle against the Almohads was immensely draining on Almoravid resources and contributed to their shortage of manpower elsewhere, including in al-Andalus. It also required the construction of large fortresses in the Almoravid heartlands in present-day Morocco, such as the fortress of Tasghimut. On Ali ibn Yusuf's orders, defensive walls were built around the capital of Marrakesh for the first time in 1126. In 1138, he recalled his son, Tashfin, to Marrakesh in order to assist in the fight against the Almohads. Removing him from al-Andalus only further weakened the Almoravid position there.

In 1138, the Almoravids suffered a defeat at the hands of Alfonso VII of León and Castile. In the Battle of Ourique (1139), they were defeated by Afonso I of Portugal, who thereby won his crown. During the 1140s, the situation grew steadily worse.

According to some scholars, Ali ibn Yusuf represented a new generation of leadership that had forgotten the desert life for the comforts of the city. After his death in 1143, his son Tashfin ibn Ali lost ground rapidly before the Almohads. In 1146, he was killed in a fall from a precipice while attempting to escape after a defeat near Oran. The Muridun staged a major revolt in southwestern Iberia in 1144 under the leadership of the Sufi mystic Ibn Qasi, who later passed to the Almohads. Lisbon was conquered by the Portuguese in 1147.

Tashfin's two successors were Ibrahim ibn Tashfin and Ishaq ibn Ali, but their reigns were short. The conquest of Marrakesh by the Almohads in 1147 marked the fall of the dynasty, though fragments of the Almoravids continued to struggle throughout the empire. Among these fragments, there was the rebel Yahya Al-Sahrāwiyya, who resisted Almohad rule in the Maghreb for eight years after the fall of Marrakesh before surrendering in 1155. Also in 1155, the remaining Almoravids were forced to retreat to the Balearic Islands and later Ifriqiya under the leadership of the Banu Ghaniya, who were eventually influential in the downfall of their conquerors, the Almohads, in the eastern part of the Maghreb.
startend:end_checker, length_constraints:number_words[147], combination:repeat_prompt