thumb|[[Sidi Kacem El Jellizi Mausoleum|Zawiya of Sidi Qasim al-Jalizi in Tunis: view of the courtyard leading to the mausoleum chamber]]

A zawiya or zaouia (; ; also spelled zawiyah or zawiyya) is a building and institution associated with Sufis in the Islamic world. It can serve a variety of functions such a place of worship, school, monastery and/or mausoleum. In some regions the term is interchangeable with the term khanqah, which serves a similar purpose. In the Maghreb, the term is often used for a place where the founder of a Sufi order or a local saint or holy man (e.g. a wali) lived and was buried. Their curriculum began with memorization of the Arabic alphabet and the later, shorter suras of the Qur'an; if a student was sufficiently interested or apt, it progressed to law (fiqh), theology, Arabic grammar (usually taught with ibn Adjurrum's famous summary), mathematics (mainly as it pertained to the complex legal system of inheritance distribution), and sometimes astronomy. These are still operational throughout the Maghreb, and continue to be a major educational resource in the Sahel of West Africa, from Mauritania to Nigeria.

History

thumb|[[Zawiya of Sidi Sahib in Kairouan (rebuilt in the 17th century)]]

The zawiya as an institution pre-dates the arrival of formal tariqas in North Africa and traces its origins to the qubba tombs which sometimes acted as shrines and to the early ribats on the frontier of the Islamic world to which holy men sometimes retired with their followers. The first formal zawiyas in Morocco were founded under the Marinid dynasty in the 14th century as well, most notably the zawiya built in Chellah by Abu al-Hasan and the Zawiyat an-Nussak built by his successor Abu Inan in Salé. Both examples, partly ruined today, were similar to madrasas in form and function. In Algeria, another major example is the religious complex of Sidi Abu Madyan (or Sidi Boumediene), also founded by Abu al-Hasan and built around the older tomb of Abu Madyan (d. 1197). In Fez, the tomb of Idris II, a sharif (descendant of Muhammad) and one of the city's founders, was rebuilt in the early 14th and early 15th centuries and maintained by his Idrisid descendants. In Tunis, the Zawiya of Sidi Ben 'Arus and the Zawiya of Sidi Qasim al-Jalizi, two of the most important zawiyas in the city, were both established near the end of the 15th century around the tombs of important saints. During periods of weak central rule Sufi orders and zawiyas were able to assert their political power and control large territories. In particular, during the so-called Maraboutic Crisis in the 17th century the Dila Zawiya (or Dala'iyya), a Sufi order among the Berbers of the Middle Atlas, rose to power and controlled most of central Morocco, while another zawiya order based in the town of Iligh ruled the Sous region. The Zawiya al-Nasiriyya in Tamegroute, which still exists today, also ruled as an effectively independent principality to the southeast during this time.

By the 19th century, zawiyas, both as individual institutions and as popular Sufi tariqas, had large and widespread memberships across the population of the Maghreb. The Sanusiyya tariqa, for example, was widespread and influential in Libya and the eastern Sahara regions. The term zawiya, on the other hand, was for smaller, less formal institutions of popular Sufism that were usually devoted to a specific shaykh and a specific Sufi brotherhood. In the early Ottoman Empire, the cognate term zaviye usually designated a multi-purpose religious complex that catered to Sufis and served as a place of worship.