History of medieval Tunisia
The medieval era of Tunisia began with what would eventually return Ifriqiya (Tunisia and the entire Maghrib) to local Berber rule. The Shia Islamic Fatimid Caliphate departed to their newly conquered territories in Egypt leaving the Zirid dynasty to govern in their stead.
Source: Wikipedia — History of medieval Tunisia (CC BY-SA 4.0)