A zawiya or zaouia (زاوية; zaviye; 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. In the Maghreb the word can also be used to refer to the wider tariqa (Sufi order or brotherhood) and its membership.
In the Maghreb (Morocco, Algeria, Tunisia and Libya) the zawiya is primarily a place for religious activities and religious instruction. It is typically associated with a particular religious leader (shaykh) or a local Muslim saint (wali), who is housed here along with his family. After his death, the zawiya usually houses his tomb, commonly inside a qubba (chamber covered by a dome or pyramidal cupola), which is sometimes a shrine that serves as the focus of a minor pilgrimage (a ziyarat). Typically, his descendants continue to lead or maintain the zawiya afterwards. Some zawiyas, particularly in urban areas, are simply meeting places for local members of a wider Sufi order or brotherhood (tariqa), where they perform activities such as a haḍra or a dhikr. Some zawiyas, particularly in rural areas, serve as larger complexes which provide accommodation to pilgrims and contain a library, mosque, workshops, and granaries that serve the local community. Such zawiyas also historically mediated disputes between tribes or between local communities and the central government. In some cases zawiyas could provide asylum to individuals and could wield considerable political and commercial influence in the region. They were financed with the help of waqfs (also known as habous), charitable endowments that were inalienable under Islamic law.