ʻUqbah ibn Nāfiʻ, on his return from the victorious Battle of Vescera in the Atlas Mountains, was killed by the army of the Berber Christian king Kusayla ibn Lamzah in an ambush outside the town of Thouda in 683. His corpse was buried in the current Sidi Okba, and later the mosque was built on top of it for commemoration. It is not exactly recorded who built the mosque. Historians consider that it was the followers of Uqba who were captured during the battle, and later redeemed by the judges in Tunis from the prison. Commander Zuhayr ibn Qays sent them back along with other Muslims to Thouda, where they built the mosque. The building was initially built in very simple manner, entirely by limestone mortars, and there was no precious materials being used. This architectural style resembled some of the oldest Islamic architectures and the mosques built by the hand of Muhammad himself. Certain architectural elements were also similar to the mosques built during the time, including the qibla wall. The mosque had been renovated several times, some of which records were lost and difficult to assess the exact date and details. One of the renovations were conducted in 1025 under the rule of Zirid emiral-Mu'izz ibn Badis. According to the inscription inscribed in the mausoleum which uses the similar letters being used as well in the Great Mosque of Kairouan, a decorative door was added to the mosque. In the 14th century, a zawiya was instituted by the Awlad Mourat. During Ottoman Algeria, another renovation was conducted by the wali Mohamed ben Omar al-Tunisi, and this is inscribed on the mihrab as the year 1789. There are other inscriptions designating the dates of renovations as well, including the decoration of the painting on the wall which designates the year 1800.
Architecture
The mosque is irregularly shaped with 60 meters length and 37 meters width. It consists of three hallways and the main door at the south. The mihrab is decorated with simple interlace pattern and irregular layout, and it is covered by the semi-dome. The cavern which covers the prayer hall has two domes, one above the mausoleum and the other facing the qibla wall.