The city of Kairouan in northern Tunisia is generally regarded as the fourth holiest city in Islam (after Mecca, Medina, and Jerusalem). The Great Mosque of Kairouan was the first Muslim place of prayer in North Africa and remains an important pilgrimage destination today.
The name Kairouan means "caravan," indicating the city's origins as a settlement where desert trade carvans stopped. It is well watered, and thus became an important strategic site during the invasions of the seventh century. A military outpost by 670, it was resettled in 694 as an Islamic religious center, cut off from the surrounding Christian and Jewish populations, which had not yet begun to die out. Only Muslims were allowed entrance inside the walls until modern times, and the city has served as a sanctuary of orthodox Islam standing against both non-Muslim infidels and heretical forms of Islam.
In the 9th century, Kairouan was a major endpoint of the lucrative trans-Sahara trade routes, and it became wealthy and powerful, but the city fell to the Fatmids in 909 AD and declined after the capital was moved to Mahdia. Kairouan was again sacked in 1057 during the Hilalian invasions, and never regained its political prominence. However, Kairoan has always maintained its importance as a seat of Islamic scholarship and holy city, and a significant part of its economic base then – as now – was the pilgrimages to its many holy places. Today, Kairouan has a population of 118,000 and is "fundamentally Tunisian – Islamic to its core and with deep roots in tradition, but adapted to the commercial necessities of the modern world" (Lonely Planet Tunisia).