In 2014, the city had about 186,653 inhabitants.
The name (Arabic: القيروان Al-Qairuwân is an Arabic version, of the Persian word کاروان kârvân, meaning "military/civilian camp" (kâr [war/military] (akin to Latin guer, + vân [outpost]), "caravan", or "resting place" (see caravanserai).
Kairouan, the capital of Kairouan Governorate, lies south of Sousse, 50 km (31 mi) from the east coast, 75 km (47 mi) from Monastir and 184 km (114 mi) from Tunis.
The foundation of Kairouan dates to about the year 670 when the Arab general Uqba ibn Nafi of Amir Muauia selected a site in the middle of a dense forest, then infested with wild beasts and reptiles, as the location of a military post for the conquest of the West. Formerly, the city of Kamounia was located where Kairouan now stands. It had housed a Byzantine garrison before the Arab conquest, and stood far from the sea – safe from the continued attacks of the Berbers who had fiercely resisted the Arab invasion. Berber resistance continued, led first by Kusaila, whose troops killed Uqba at Biskra about fifteen years after the establishment of the military post, and then by a Berber woman called Al-Kahina who was killed and her army defeated in 702. Subsequently, there occurred a mass conversion of the Berbers to Islam. Kharijites or Islamic "outsiders" who formed an egalitarian and puritanical sect appeared and are still present on the island of Djerba. In 745, Kharijite Berbers captured Kairouan, which was already at that time a developed city with luxuriant gardens and olive groves.
Power struggles continued until Ibrahim ibn al-Aghlab recaptured Kairouan at the end of the 8th century. In 800 Caliph Harun ar-Rashid in Baghdad confirmed Ibrahim as Emir and hereditary ruler of Ifriqiya. Ibrahim ibn al-Aghlab founded the Aghlabid dynasty which ruled Ifriqiya between 800 and 909. The new Emirs embellished Kairouan and made it their capital. It soon became famous for its wealth and prosperity, reaching the levels of Basra and Kufa and giving Tunisia one of its golden ages long sought after the glorious days of Carthage.
The Aghlabites built the great mosque and established in it a university that was a centre of education both in Islamic thought and in the secular sciences. Its role can be compared to that of the University of Paris in the Middle Ages. In the 9th century, the city became a brilliant focus of Arab and Islamic cultures attracting scholars from all over the Islamic World. In that period Imam Sahnun and Asad ibn al-Furat made of Kairouan a temple of knowledge and a magnificent centre of diffusion of Islamic sciences. The Aghlabids also built palaces, fortifications and fine waterworks of which only the pools remain. From Kairouan envoys from Charlemagne and the Holy Roman Empire returned with glowing reports of the Aghlabites palaces, libraries and gardens – and from the crippling taxation imposed to pay for their drunkenness and sundry debaucheries. The Aghlabite also pacified the country and conquered Sicily in 827.
In 893, through the mission of Abdullah al Mahdi, the Kutama Berbers from the west of the country started the movement of the Shiite Fatimids. The year 909 saw the overthrow of the Sunni Aghlabites who ruled Ifriqiya and the establishment of the Shiite Fatimid dynasty. During the rule of the Fatimids, Kairouan was neglected and lost its importance: the new rulers resided first in Raqqada but soon moved their capital to the newly built Al Mahdiyah on the coast of modern Tunisia. After succeeding in extending their rule over all of central Maghreb, an area consisting of the modern countries of Morocco, Algeria, Tunisia and Libya, they eventually moved east to Egypt to found Cairo making it the capital of their vast Caliphate and leaving the Zirids as their vassals in Ifriqiya. Governing again from Kairouan, the Zirids led the country through another artistic, commercial and agricultural heyday. Schools and universities flourished, overseas trade in local manufactures and farm produce ran high and the courts of the Zirids rulers were centres of refinement that eclipsed those of their European contemporaries.
When the Zirids declared their independence from Cairo and their conversion to Sunni Islam in 1045 by giving allegiance to Baghdad, the Fatimid Caliph Ma'ad al-Mustansir Billah sent as punishment hordes of troublesome Arab tribes (Banu Hilal and Banu Sulaym) to invade Ifriqiya. These invaders so utterly destroyed Kairouan in 1057 that it never regained its former importance and their influx was a major factor in the spread of nomadism in areas where agriculture had previously been dominant. Some 1,700 years of intermittent but continual progress was undone within a decade as in most part of the country the land was laid to waste for nearly two centuries. In the 13th century under the prosperous Hafsids dynasty that ruled Ifriqiya, the city started to emerge from its ruins. It is only under the Husainid Dynasty that Kairouan started to find an honorable place in the country and throughout the Islamic world. In 1881, Kairouan was taken by the French, after which non-Muslims were allowed access to the city.
Jews were among the original settlers of Kairouan, and the community played an important role in Jewish history, having been a world center of Talmudic and Halakhic scholarship for at least for three generations. The community disbanded in 1270 CE when the Hafsids forbade non-Muslims from living in the city; the remaining Jews were forced to convert to Islam or to leave.
The most important mosque in the city is the Great Mosque of Sidi-Uqba (Uqba ibn nafée) also known as the Great Mosque of Kairouan. It has been said that seven pilgrimages to this mosque is considered the equivalent of one pilgrimage to Mecca. After its establishment, Kairouan became an Islamic and Qur'anic learning centre in North Africa. An article by Professor Kwesi Prah describes how during the medieval period, Kairouan was considered the fourth holiest city in Islam after Mecca, Medina and Jerusalem. Today, many consider the city as the fourth holiest in Islam.
In memory of Sufi saints, Sufi festivals are held in the city.
At the time of its greatest splendor, between the ninth and eleventh centuries AD, Kairouan was one of the greatest centers of Islamic civilization and its reputation as a hotbed of scholarship covered the entire Maghreb. During this period, the Great Mosque of Kairouan was both a place of prayer and a center for teaching Islamic sciences under the Maliki current. One may conceivably compare its role to that of the University of Paris during the Middle Ages.
In addition to studies on the deepening of religious thought and Maliki jurisprudence, the mosque also hosted various courses in secular subjects such as mathematics, astronomy, medicine and botany. The transmission of knowledge was assured by prominent scholars and theologians which included Sahnun ibn Sa'id and Asad ibn al-Furat, eminent jurists who contributed greatly to the dissemination of the Maliki thought, Ishaq ibn Imran and Ibn al-Jazzar in medicine, Abu Sahl al-Kairouani and Abd al-Monim al-Kindi in mathematics. Thus the mosque, headquarters of a prestigious university with a large library containing a large number of scientific and theological works, was the most remarkable intellectual and cultural center in North Africa during the ninth, tenth and eleventh centuries.
A unique religious tradition in Kairouan was the use of Islamic law to enforce monogamy by stipulating it in the marriage contract, a practice common among both elites and commoners. This stipulation gave a woman legal recourse in the case that her husband sought to take a second wife. Although the introduction of the 1956 Code of Personal Status rendered the tradition obsolete by outlawing polygamy nationwide, some scholars have identified it as a "positive tradition for women within the large framework of Islamic law."
The city's main attraction is the Great Mosque of Sidi-Uqba, which is said to largely consist of its original building materials. In fact most of the column stems and capitals were taken from ruins of earlier-period buildings, while others were produced locally. There are 414 marble, granite and porphyry columns in the mosque. Almost all were taken from the ruins of Carthage. Previously, it was forbidden to count them, on pain of blinding. The Great Mosque of Kairouan (Great Mosque of Sidi-Uqba) is considered as one of the most important monuments of Islamic civilization as well as a worldwide architectural masterpiece. Founded by Arab general Uqba Ibn Nafi in 670 CE, the present aspect of the mosque dates from the 9th century. The Great Mosque of Sidi-Uqba has a great historical importance as the ancestor of all the mosques in the western Islamic world.
The Mosque of the Three Gates was founded in 866. Its façade is a notable example of Islamic architecture. It has three arched doorways surmounted by three inscriptions in Kufic script, interspersed with floral and geometrical reliefs and topped by a carved frieze; the first inscription includes the verses 70–71 in the sura 33 of Quran. The small minaret was added during the restoration works held under the Hafsid dynasty. The prayer hall has a nave and two aisles, divided by arched columns, parallel to the qibla wall.
The Mausoleum of Sidi Sahab, generally known as the Mosque of the Barber, is actually a zaouia located inside the city walls. It was built by the Muradid Hammuda Pasha Bey (mausoleum, dome and court) and Murad II Bey (minaret and madrasa). In its present state, the monument dates from the 17th century.
The mosque is a veneration place for Abu Zama' al-Balaui, a companion of the prophet Muhammad, who, according to a legend, had saved for himself three hairs of Muhammad's beard, hence the edifice's name. The sepulchre place is accessed from a cloister-like court with richly decorated ceramics and stuccoes.
Kairouan is also home to:two large water reservoirs called "Aghlabid basins"
Mosque of Ansar (traditionally dating to 667, but totally renewed in 1650)
Mosque Al Bey (late 17th century)
The souk (market place), in the Medina quarter, which is surrounded by walls, from which the entrance gates can be seen in the distance. Products that are sold in the souk include carpets, vases and goods made of leather.
Kairouan is known for its pastries (e.g. zlebia and makroudh).
Kairouan was used as a filming location for the 1981 film Raiders of the Lost Ark, standing in for Cairo. As the film is set in 1936, television antennas throughout the city were taken down for the duration of filming.