Towards the end of the 8th century, with the exception of Tunisia, the Western part of the Maghreb had sized to acknowledge the authority of the Abbasids the Caliph. But at the beginning of the 9th century, Ibrahim Aghlab who helped in the suppression of a revolt by the garrison stationed at Tunis against the Abbasids, instead of returning the Tunisian governor, Aghlab usurped his position. The Caliph who was powerless to assert his authority accepted his usurpation and recognized Aghlab as governor of Tunisia. Aghlab converted the governorship of Tunisia into a hereditary right and by enforcing considerable autonomy of Tunisia, the Aghlabids managed to carve out for themselves an independent state – Aghlabids State.
The Aghlabids State comprise of Tunisia and Eastern Algeria. The Aghlabids Dynasty esterblished in Tunisia from 800-900 AD and they preserved their dynastic autonomy although they paid regular tribute to the Caliph and said prayers in the name of the Caliph. Though they were very unpopular especially with the religious circle of the country, They adopted the title Amir. Most of them were said to have led a hedonistic life. They were also said to have imposed heavy taxes that were against the Muslim law.
Aghlabids State was never in peace. Most of the rebellions came from the regular Arab army that was stationed in Tunis. This insubordination of the army could be explained in the unpopularity of the Aghlabids with the religious circle in the country especially the Orthodox religious centre of Quarawan. By the 9th Century, Quarawan had become an important centre of religious learning. Muslim laws especially Malikites rites and the major theological controversies of the Muslim east echoed largely in Quarawan. It is no wonder then that the non Muslim habits of the Aghlabids were condemned in Quarawan. It is also possible that the never ending revolts of the army called the Jund were instigate from the centre. To win the favor of this religious dignitaries, the Aghlabids Princes were lavish in their construction of religious buildings. They rebuilt the great Mosque of Quarawan and Tunis.
These were however not the only contribution of the Aghlabids to the development of their country. If Mosques and religious buildings were constructed for the purpose of internal peace, fortresses were built on the Tunisia Coastline for the protection of the country from external invaders. These fortresses were built mostly on Byzantine foundation. From all indication, the fact that the Aghlabid knew no period of peace and the Arab garrison on their door step made their major construction securely oriented.
The building of a fortified palace at Raqqada was prompted by the first two rebellions of the Jund in 802 and 807 AD. This palace was built by Ibrahim Aghlab and it was situated near Quarawan.
The Aghlabid also built a fortified Monastery called the Ribat at Susa