At the start of the 11th century, the Moroccan statelets were united by the first of two great Moroccan Muslim empires. For the next two centuries north-west Africa was united by political movements originating in the deserts and mountains rather than the coast and plains.
Islam had unified the desert tribes through trade and religious warfare, but the religion was not very orthodox. In the mid-11th century, the leader of one powerful desert tribe, the Gudala, recruited a preacher to instruct his people in orthodox Islam. He was Abdallah ibn Yasin, and what he taught was so rigorous that the Gudala expelled him. He and a few like-minded followers found refuge in a ribat, a fortified post and/or religious centre, and set up a highly disciplined society. They were known as al-Murabitun, ‘people who dwell in a ribat‘, or ‘people who are bound together in piety’. The English name ‘Almoravid’ derives from it.
To spread his message more widely, Ibn Yasin allied with other Saharan tribes to unify Islam on both sides of the desert by seizing control of the desert trade routes. They took Sijilmasa in 1053 and Aoudaghost, on the southern side of the Sahara, in 1054.
By 1058 Ibn Yasin’s most important general, Abu Bakr ibn Umar, had defeated the small kingdom of Aghmat, north of the High Atlas. There he married Zaynab, the beautiful widow of its last ruler, who had prophesied she would marry only the man who conquered all Morocco. Abu Bakr founded a military base called Marrakesh, near Aghmat, probably in 1070, but abandoned his wife to return to fighting in the desert. His cousin, Yusuf ibn Tashfin, took over the leadership, fulfilled Zaynab’s prophecy by marrying her, conquered the rest of Morocco, and founded a new empire.
In 1075 Ibn Tashfin’s huge army moved north and took Fez, where he began a huge building program, including mills, baths, and fondouks (urban caravanserais). By 1082, he ruled Tlemcen, Oran, and Algiers. In 1083, the Almoravids took Ceuta and prepared to cross the Strait. Al-Andalus was divided among princelings who were too weak to fight the advancing Christians. The King of Seville, Abbad II al-Mutadid, asked the Almoravids for help. On 23 October 1086 they halted the Christian advance at Zallaca, north-east of Badajoz.
The Almoravids were Sunnis who interpreted the Koran literally. Their austere morality, based on rigorous legalistic elitism, offered little to the population except strictly Koranic (and thus lower) taxes. Marrakesh attracted to Islam scholars from all over, but the Almoravids’ narrow-mindedness collided with the Sufi mysticism, which was developing at the end of the 11th century, and with Sufi writings. Almoravid architecture was splendid but was destroyed almost entirely by the later Almohads: the huge palace in Marrakesh was estimated to cover 9,600 square metres. All that remains is the elaborate system of underground irrigation channels (khattara) that water gardens around Marrakesh, and the huge defensive walls.
The Almoravid dynasty began to decline during the reign of Yusuf’s son Ali (1106-1143), who was more a scholar than a soldier. The empire was divided into its Saharan and Maghrebi parts, depriving Marrakesh of manpower, although trade continued unfettered. The war in al-Andalus drained both manpower and finances. Tashfin ibn Ali (r. 1143-1145) could not resist the Christians in Iberia, and in Morocco he faced a new Berber ‘prophet’.