The Muslim conquest of North Africa in the final decades of the 7th century was a by-product of the conquests further east: Persia, Mesopotamia, Syria, and Egypt were far richer and more sophisticated societies. Situated on the political periphery, North African states quickly emerged that were ruled by Muslims but washed over by the great political events in the east rather than influencing their course. While the Maghreb was incorporated into the Islamic world, it quickly went its own way politically.
Early Islam was rent by a long struggle in the decades following the death of the Prophet, who had designated no successor. Abu Bakr and Umar, the first two caliphs (Arabic khalifa, successor or deputy to the Prophet) were chosen by the Meccan elite, with little opposition from the community. Under the third caliph, Uthman, a rift occured within the community over the Prophet’s succession and he was eventually murdered (as was Umar before him). It was under these three leaders that the conquest of North Africa began, with the taking of Egypt in 641. The controversy over the succession led Uthman’s opponents to gather round the family of Muhammad’s daughter Fatima and her husband Ali. Ali became caliph, but the Meccan elite soon deposed him. The first split that emerged in Islam was between those who believed that the caliph should come from among Muhammad’s descendants and those who believed that the caliph should be chosen by the Meccan elite. Ali’s party, the Shiat Ali, or Shiites, became a permanent focus of dissent from mainstream Muslims, known as Sunnis.
Ali’s line of Shiite imams, or leaders, continued until the 9th century, when the twelfth imam disappeared, leaving his followers with the hope that he had merely gone into hiding and would return to lead a revolutionary period of justice and truth that would finally prevail. Supporters of an alternative seventh imam had the same idea: Shiites combined millenarian ideals with descent from Fatima and Ali.
A third group rejected both Sunnis and Shiites, saying that descent or oligarchy was no way to choose the leader of the community. Only a man chosen for his piety and his probity was acceptable. This group left the main community and so were described as Kharijites, ‘those who go out’. They sought refuge in remote areas, such as the desert and the peripheries of Islam (Iraq and North Africa).
It was the mainstream Sunnis who continued the invasion of North Africa after their leader Muawiya seized the caliphate in 661 and established the Umayyad dynasty. Uqba ibn Nafi led the attack in 662. By 674 he had moved across the desolate desert of Libya to found a new base at Kairouan, in what is now Tunisia. Kairouan, which became the Islamic capital of North Africa, gradually changed from a military camp into a great centre of learning, government, and trade. From Kairouan, Uqba struck inland across the central plateau and in 682 reached the Atlantic coast.
The advance was not opposed by the Christian inhabitants of the coast, because they were not forced to convert. Few Berbers were Christians, and although some were Jews, most were animists. Pagans could be forced to submit, although the Muslims found it hard to break Amazigh resistance. They did eventually convert but were irked by their second-class status and open to the influence of heterodox movements such as the Shiites and Kharijites.
To a large extent, the rule of the Umayyads, from Damascus, and the later Abbasid dynasty, from Baghdad, was confined to the North African coast. In the 720s Ibadi propagandists, a moderate offshoot of the Kharijites, reached Tripolitania and took root in Jebel Nafusa. Encouraged by the Ibadi leadership in Iraq, they formed a local imamate that took Tripoli in 757 and Kairouan in 758. In 761 the Abbasid governor of Egypt defeated the Ibadis at Tawergha.
The Abbasids’ governors in Kairouan, members of the Aghlabid family, who became virtually autonomous at the start of the 9th century pushed the Ibadis further back into the interior, where they founded an imamate at Tiaret, in Algeria, which effectively controlled the Jebel Nafusa until it was overrun by the Aghlabid ruler Ibrahim II in 897. Although there were brief attempts to found Ibadi states in Tripolitania, these died out under the Fatimids in the 11th century, after which the Ibadis were confined to isolated communities in the Mzab (Algeria), Djerba (Tunisia), and the Jebel Nafusa.
At the end of the 9th century, North Africa became host to another heterodox group, the Shiite Ismailis. They originated in Syria, where a man named Ubayd Allah announced that he was a descendant of the hidden Imam, through the vanished seventh Imam, Ismail. One of his propagandists, Abu Abdullah, arrived in the Maghreb in 893 and quickly won support. In 909 he defeated the last Aghlabid ruler and was able to give protection to Ubayd Allah when he fled to the Maghreb and declared himself caliph, the head of a new dynasty called the Fatimids. The Fatimids were the only important Shiite caliphate in the history of Islam, and their eventual aim was to conquer the Arab east. Their Tunisian capital, Mahdia, was built on a peninsula facing east into the Mediterranean, and eventually, in 972, they were able to conquer Egypt and moved the seat of the caliphate to Cairo. Once they had done so, control of the Maghreb began to slip away, and local dynasties began to reassert themselves. Tripoli fell under the control of the Zirid dynasty, Berbers who originated in what is now Algeria. They had once served the Fatimids faithfully, and, following the move to Cairo, they were appointed governors of the central Maghreb, but after a split with the Algerian branch of the family, they abandoned the Shiite ideology of their nominal overlords in the mid-11th century and ruled what is now Tunisia and western Libya from Kairouan. Supposedly, they paid allegiance to the shadowy Abbasid caliphate in Baghdad, but they were actually independent and, for a while, prosperous and powerful.
By the mid-11th century, however, North Africa was afflicted by an economic and social crisis. Two great confederations of Arab tribes moved in from the east, the Banu Hilal and the Banu Sulaym. The traditional view is that they were sent to the Maghreb by the Fatimids to bring the Zirids to heel, ruining the economy of the region in the process. Another view holds that the economic collapse was the result of internal factors. A more recent hypothesis is that the whole concept of ruin is greatly exaggerated and that the arrival of the Banu Hilal and the Banu Sulaym came about because of a long period of tribal movement. This began in Arabia, where they originated, but they were severely affected by a devastating earthquake in the north-west desert in 873 and then moved into the area west of the Nile and on into the Maghreb.
As Zirid rule weakened, agriculture declined and insecurity grew. After they lost Kairouan in 1057, the rule of the Zirids was confined to a coastal strip of Tunisia based on the old Fatimid capital at Mahdia. Two outside powers moved in: one was the Christian Normans of Sicily, who conquered all the coastal towns, including Tripoli, between 1146 and 1148, and the other was the Almohad dynasty based in Marrakesh, in what is now Morocco. In 1151 Almohad troops moved east and in 1152 occupied Algiers, Constantine, and Bejaïa. In 1159 they took Tunis and retook Mahdia, Sfax, and Tripoli from the Normans. This was not liberation: the first caliph of the Almohad empire Abd al-Mumin treated the central and eastern Maghreb as conquered lands and taxed them as though they had been newly occupied by Muslims.
Almohad rule did not last long: by the beginning of the 13th century it was increasingly weakened by the collapse of the tax base and by a series of defeats by the Christian armies in Spain. Then the Almohad governor in Tunis broke away and set up a local dynasty, the Hafsids, who claimed the caliphate of Islam for themselves, although even at its height it never extended much beyond Tripoli in the east and central Algeria in the west and they were twice conquered by the Marinids, who ruled Morocco following the Almohad collapse. By the early 15th century the Hafsids had rebuilt their state, and it became prosperous, partly through trade and partly through privateering attacks on Christian shipping. In the second half of the 15th century the Hafsids reached their economic zenith, strengthened by the arrival of a wave of refugees fleeing persecution in Christian Spain, who became heavily involved in manufacturing, trade, and sea raiding. But even the Hafsids were no more than a coastal phenomenon.
The political history of Fezzan was a different story. It was a long time before it was incorporated into the Arab sphere, although it had been conquered by Uqba ibn Nafi in 666 or 667. In the early 10th century, the town of Zwila, founded by a Berber named Ibn Khattab al-Hawwari, ruled Fezzan. It flourished as a centre of the slave trade and had a prosperous irrigated agriculture. Later chronicles blame the decline of Zwila on the Banu Hilal and Banu Sulaym.
Between the 13th and 15th centuries, Fezzan was controlled by the kings of Kanem in what is now Chad and Nigeria, but wars between Kanem and Bornu (in Nigeria) in the early 16th century allowed a Moroccan tribal group, the Awlad Muhammad, to take over Fezzan, with their capital at Murzuq.