The Great Mosque is located at the Eastern end of the medina, about fifty meters away from the ribat. It was constructed by the Aghlabid prince Abû al-Abbas Muhammad in AH 237 / AD 851.
The mosque has a rectangular floor plan and comprises a courtyard with columned porticoes onto which the prayer hall opens. The three porticoes with pointed arches rest on very short pillars dating from the first phase of construction of the monument. The fourth portico, on the prayer room side, rests on columns and was probably added during the Zirid period, then was renovated during the Muradite period (AH 1086 / AD 1675).
The upper area of the three Aghlabid porticoes and the prayer hall portico is decorated with a Kufic inscription. The T-shaped prayer hall has thirteen naves and six bays, with the mihrâb bay and the axial nave, featuring twin columns, being wider than the others. The latter is also enhanced by two domes, one of which is erected in front of the mihrâb.
The first nucleus of the mosque, dating from the time of Abû al-Abbas Muhammad, comprised 13 naves roofed with barrel vaults and three bays supported by horseshoe arches resting on cross- shaped pillars. Under Ibrahim II (875-902), the prayer hall was enlarged by the addition of three bays and a new mihrâb, with a domed trumpeted roof. This semi cylindrical mihrâb is ornamented with Zirid motifs, as attested to by the niches on columns decorating the cul-de-four and the inscriptions in flowery kufic script on the antique reused columns, that are placed on both sides of the niche.
The massive and stark aspect of the building is reminiscent of ribats’ architecture, and its relationship with hydraulic and underground architecture is striking. It will become distinctive of the Sahelian architecture of Tunisia.