In Summer 407 AH/1016 AD, a massive pogrom targeting Isma’ili Shi’i Muslims erupted in Ifrīqiyah, a province of the Fatimid caliphate ruled by the Zirid dynasty and consisting of the territories of modern-day Tunisia, western Libya and eastern Algeria. Following their move to Egypt in the late 10th century, the Fatimid caliphs had appointed the Zirids, a dynasty of Sanhaja Berbers, as their governors and deputies in North Africa. Despite occasional outbreaks of violence, for much of the 10th century, there had been a delicate, albeit uneasy, coexistence between the various Muslim communities in Ifrīqiyah (Isma’ili Shi’is, Hanafis, Malikis, and Ibadis). The pogrom of 1016 was therefore a cataclysmic event that shattered this heterogeneous society.
(Fatimid caliphate at its greatest extent)
The massacres, which began in Qayrawan and spread across North Africa, claimed the lives and property of thousands of Isma’ili Shi’is, essentially ending the existence of Isma’ilism as a significant presence in Ifrīqiyah, where it had thrived for over a century. Although never a majority of the population, the Isma’ilis were a privileged religious minority whose social status, association with the Fatimid authorities and religious faith made them a target of the (largely Sunni) populace. This violence, which was underpinned by various social, political, economic and religious factors did not occur in a vacuum. The broader context of its occurrence can be seen in the increasing sectarian tensions throughout the Fatimid caliphate during the reign of al-Ḥākim bi Amr-illāh (r. 386/996–412/1021), whose repressive social and religious policies alienated large numbers of his Sunni subjects. Moreover, the increasingly anti-Isma’ili theological discourse among many Sunni communities across the Islamic world, best exemplified by the theological creed issued by the Abbasid caliph al-Qādir (r. 381/991–422/1031) in Baghdad, also played a role in legitimizing such anti-Shi’i violence. In addition, the roots of the violence may be located in the staunch opposition of the Maliki scholars (and their followers) to Isma’ili Shi’ism and the Fatimid regime’s social and religious policies. The massacres in Zirid Ifrīqiyah marked the beginning of the end of Fatimid rule in North Africa and formed the immediate background for the Zirids formal renunciation of the Fatimids and declaration of allegiance to the Abbasids. As noted by various chroniclers and modern scholars, the massacres and their broader context cannot be separated from the broader process of the establishment of the exclusive hegemony of the Maliki school of thought in North Africa.
(The Zirid emirate around 1000 A.D.)
Unfortunately, very few contemporary sources or eye-witness accounts have survived for this major historical event. Rather, we are forced to rely upon later historical accounts (many of which preserve earlier narrations). Nevertheless, these sources can still tell us much about the broader context and give us some insight into how these events were interpreted by later generations. The following are my translations of two particularly significant accounts by the late medieval Muslim historians ‘Izz al-Dīn ‘Alī ibn al-Athīr (d. 630/1233) and Abū Zayd ‘Abd al-Raḥmān ibn Khaldūn (d. 808/1406). Both accounts seem to indicate that it was the Zirids’ Sunni inclinations, especially during the reign of al-Mu ‘izz ibn Bādis (r. 407/1016–454/1062), that motivated the outbreak of the massacres, which are recounted in all their horrific detail. Ibn Khaldūn’s account also emphasizes that these massacres initiated the Zirid break with the Fatimids, which led the latter to facilitate the invasion of North Africa by the large confederations of the Banū Hilāl and Banū Sulaym tribes, a decision that would have catastrophic consequences for the region.
Translation: Ibn al-Athīr (d. 630/1233), al-Kāmil fï al-Tārïkh
In Muharram 407 AH [July 1016], the Shi’i communities across North Africa were massacred. The reason is as follows: when al-Mu‘izz b. Bādis [r. 407/1016–454/1062] became ruler and arrived in Qayrawan, he was greeted by large crowds of people. After encountering one of these crowds, he asked his advisors about who they were. They replied: “These are Shi’is (rāfiḍah), a group that curses Abū Bakr [ibn Abī Quḥāfah, d. 13/634] and ‘Umar [ibn al-Khaṭṭāb, d. 23/644].” So he proclaimed: “May God be greatly pleased with Abū Bakr and ‘Umar!” Hearing this, [mobs of] common people attacked Darb al-Maqlah, where large groups of Shi’is would gather, and slaughtered them all. The troops and their auxiliaries also supported and participated in these attacks due to their desire for the wealth that was to be plundered. The common folk unleashed their violence against the Shi’is, encouraged and incited further by the governor of Qayrawan.
(Great Mosque of Qayrawan, one of the oldest mosques in North Africa)
The reason that the governor of Qayrawan encouraged this violence was because he had heard that, despite his competence in maintaining order, al-Mu‘izz b. Bādis sought to remove him from office. During this outbreak of violence, large numbers of Shi’is were murdered, burned alive, and their homes were plundered. These massacres occurred throughout Ifriqiya [modern-day Tunisia, eastern Algeria and western Libya]. A large group of survivors, seeking refuge, fortified themselves in the palace of al-Manṣūr near Qayrawān, but were soon besieged by large mobs until they were on the brink of starvation. When they attempted to escape, the people slaughtered every single one of them. Even those who sought refuge in the Great Mosque of al-Mahdia were all murdered. In North Africa, the Shi’is were usually referred to as “Easterners” (al-mashāriqah), based on the eastern origin of Abū ‘Abd Allāh al-Shī‘ī [d. 298/911] eastern origin. Most of the poets have mentioned this event, with some celebrating it with happiness while others lamenting it with tears.
[‘Izz al-Dīn ‘Alï ibn al-Athīr, al-Kāmil fï al-Tārīkh (Beirut, 2008), Vol. 9, pp. 294–295]
(Great Mosque of Mahdia)
Translation: Ibn Khaldūn (d. 1406), Kitāb al-‘Ibar
Al-Mu‘izz b. Bādis was a major opponent of Shi’ism (madhāhib al-rāfiḍah) and a staunch adherent of Sunnism. From the beginning of his reign, he openly proclaimed his Sunni identity and publicly cursed the Shi’is. Shortly thereafter, he ordered the massacre of every Shi’i in his realm. The reason for this is that one day he had fallen off his horse and invoked the names of Abū Bakr and ‘Umar in his supplication for divine aid, which motivated the common folk to attack the Shi’is, massacring them in the most brutal way and even killing the leader of their community. The Shi’i caliph in Cairo was extremely displeased by this.
(Gold dinar of Fatimid caliph al-Mustansir)
The Fatimid vizier Abu’l-Qāsim [‘Alī ibn Aḥmad] al-Jarjarāʾī [vizier from 418/1027–436/1045] wrote to al-Mu‘izz warning him about the consequences of his actions. Al-Mu’izz replied harshly with insults against the Fatimid caliphs which led to a worsening of the relationship. This deterioration of relations continued until al-Mu’izz formally renounced his allegiance to the Fatimids in 440 AH  during the reign of the Fatimid caliph al-Mustanṣir [r. 427/1036–487/1094]. Al-Mu’izz had the Fatimid banners publicly burned, the caliph’s name removed from all coins and royal robes, and proclaimed the allegiance of his realm to the Abbasid caliph al-Qā’im b. al-Qādir [r. 422/1031–467/1075]. Al-Qā’im then sent Abū al-Faḍl b. ‘Abd al-Wāḥid al-Tamīmī to [al-Mu’izz] with an official investiture [recognizing his realm as part of the Abbasid caliphate]. In retaliation, the Fatimid caliph al-Mustanṣir sent against him the Hilāl confederation of Arab tribes—who had previously belonged to the Qarāmiṭa—which included the tribes of Riyāḥ, Zughba, Athbaj. This was done with the encouragement of the Fatimid vizier Abū Muḥammad al-Ḥasan b. ‘Alī al-Yāzūrī [vizier from 442/1050 to 450/1058], as we have previously mentioned in our discussion of the history of the Arabs and their arrival in Ifrīqiyah.”
[Abū Zayd ‘Abd al-Raḥmān ibn Khaldūn (d. 1406), Kitāb al-‘Ibar (Beirut, 2010), Vol. 6, p. 169–170]