Abū Isḥāq Ibrāhīm b. al-Qāsim al-Qayrawānī (d. ca. 418/1028), better known as Ibn al-Raqīq or al-Raqīq, was a high-ranking secretary and ambassador in the Zirid emirate (corresponding roughly to modern-day Tunisia, Libya and eastern Algeria), which ruled North Africa on behalf of the Fatimids following the latter’s conquest of Egypt. In addition to his influence within royal circles, he was also a celebrated poet and historian. His historical chronicle, Kitāb Tārīkh Ifrīqiyah wa al-Maghrib, had a profound influence on subsequent generations of Muslim historians, including Ibn al-Athīr (d. 630/1233), Ibn al-Abbār (d. 658/1260), Ibn ʿIdhārī (ca. 706/1306-7), al-Nuwayrī (d. 732/1331-2), Ibn Khaldūn (d. 808/1406) and al-Maqrīzī (d. 846/1442). Ibn Khaldūn, in particular, considered him to be one of the foremost experts on North African history. Although his work is now lost, many of these historians quote him at length and rely upon his chronicle for their narrations of the early Islamic history of North Africa. His history is therefore among the main sources of information for later historians seeking to understand the various developments in North Africa between the 1st/7th and 5th/11th centuries.
In Summer 407 AH/1016 AD, a wave of mass violence targeting Isma’ili Shi’i Muslims swept over 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 late 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 massacres of 1016 were therefore a cataclysmic set of events that shattered this heterogeneous society.