This ribat was built by Harthimâ ibn A'yûn, an Abbasid general and governor of Ifrîqiya, in the year 179-180 A.H. / 795-796 A.D., and has undergone numerous extensions and transformations over the ages. The primitive ribat has a regular plan with facades flanked at the corners by cylindrical towers; the one to the southeast is a watchtower, reflecting Mesopotamian influences on African military architecture.
Inside, the courtyard is surrounded by galleries onto which several rooms dedicated to the marabous open. The prayer hall is on the first floor and is organized into seven naves perpendicular to the qibla wall, with barrel vaults and two bays with arches in both directions (semicircular and basket handle
arches) falling on cruciform pillars. This distribution, first noted, was to become a set tradition in all Ifriqiyan mosques. Indeed, the architectural plan conceived for the ribat of Harthimâ was to become the model used in all major ribats of Ifriqiya that emerged along the coast during the 3rd / 9th century CE.
The entire west wing of this authentic ribat, whose surface area is estimated at one thousand three hundred square meters, was completely transformed, and the monument underwent numerous expansions in four main phases:
The first phase: a porch-like wing, the façade of which is decorated by a bay marked by an arch surmounted by five flat-bottomed niches with horseshoe arches, has been added parallel to the first entrance. The old entrance is separated from the new wing by a courtyard. This vestibule, which is reminiscent of that of the Great Mosque of Mahdia, leads to narrow rooms covered with barrel vaults. The prayer hall, which is located on the first floor, is composed of seven naves perpendicular to the qibla wall, intersected by two bays. All the naves are covered with barrel vaults, except for the axial nave, which is surmounted by a dome without arcades at the corners.
This wing is believed to date back to the middle of the 4th / 10th century AD. Indeed, a stone inscription, currently on display in the Louvre Museum, refers to work carried out by Abu al-Qasim al-Tammar in the year 355 AH / 966 CE.
The second phase: which corresponds either to an enlargement or to an old rearrangement of the ribat on the north and east sides. It is precisely during this phase that the monument was consolidated with two square towers. This work, which increased the surface area of the monument to 4,200 sq m, is believed to date from AH 828 / AD 1424, as evidenced by a commemorative Hafsid plaque engraved in naskhi script and placed above the angled entrance door.
The third phase: this phase most probably dates to the time of Ibrahim al-Sharif Pasha in AH 1115 / AD 1704 and involves modifications to certain parts, such as the rearrangement of the east wing of the ground floor, the addition of polygonal towers in the northwest and southeast corners, and the addition of the cylindrical tower in the northeast corner. All these changes were made to adapt to the development of the armament;
The fourth phase: which corresponds to the restorations and consolidations carried out by Husayn Bey II (AH 1239-51 / AD 1823-35), including the addition of towers and especially bastions.