Due to the vast size of the Abbasid Empire and the presence of several rival Islamic powers on the doorstep in 184 / 800 the Abbasids established the Aghlabid principality in North Africa to deal with the Umayyads in al-Andalus and the Idrisids in Morocco. The Abbasid caliph
Harun al-Rashid (r. 170–93 / 786–809) gave Ifriqiya (Tunisia) to Ibrahim Ibn
al-Aghlab as a hereditary principality to rule. The Aghlabids became the vassals of the Abbasids in Ifriqiya between the years 184 / 800 and 296 / 909. They rebuilt several cities and constructed many military fortifications along the Ifriqiyan coast to rebuke the Byzantines who had conquered Sicily several centuries before. They also organised civic affairs and developed communication routes between North Africa and the Middle East.