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. The Zirids would eventually break all ties to the Fatimids and formally embrace Sunni Islamic doctrines.