A khanqah or khaniqah (also transliterated as khankahs , khaneqa, khanegah or khaneqah (Persian: خانقاه‎‎)), also known as a ribat (رباط) – among other terms – is a building designed specifically for gatherings of a Sufi brotherhood or tariqa and is a place for spiritual retreat and character reformation. In the past, and to a lesser extent nowadays, they often served as hospices for salik (Sufi travelers) and talibe (Islamic students). Khanqahs are very often found adjoined to dargahs (shrines of Sufi saints), mosques and madrasas (Islamic schools).

In the Arab world, especially North Africa, the khanqah is known as a zāwiyah (Arabic: زاویه‎‎, plural zāwiyāt; also transliterated as zawiya, zāwiya or zaouia). In Turkey, Iran and formerly Ottoman areas like Albania and Bosnia, they are locally referred to as tekije (تكيه; also transliterated as tekke, tekyeh, teqe or takiyah). In South Asia, the words khanqah and dargah are used interchangeably for Sufi shrines.

All khanqahs, regardless of size, feature a large central hall. The daily ritual prayers incumbent on all Muslims, salat, are held in this hall, as are the specifically Sufi forms of dhikr, meditation and celebration of the divine.

Large khanqahs often grew up around the dargah of a tariqa's founder or of a Sufi saint.

Some khanqahs include dwellings for the Sufi sheikh or pir, and his family, or cells for Sufis who wish to pursue their dhikr in quiet and isolation. They may also include lodgings for traveling Sufis and pilgrims and premises for charities such as hospitals.

Sufi movements have been banned in some Muslim-majority countries such as Turkey, Iran, Saudi Arabia, or the communist and post-communist states of Central Asia. In these countries, khanqahs have been converted to other purposes, turned into museums or mosques. In other countries, Sufism survives and the old khanqahs are still in use.