Mosques, as places of worship in Islam, are places where Muslims fulfill their religious duties and unite. Muslims coming together in a place of worship ensures that the theoretical principles of religion combine with folk culture and are reflected concretely in life. Dervish lodges, where the Sufi interpretation of Islam is kept alive, also integrate folklore and Islam. Throughout the historical process, Muslims have had to build underground mosques for various reasons. These mosques have functions similar to dergahs, inns and caravanserais, other elements of Islamic architecture. Mangistau, one of the regions where Sufi Islam is most vital in Kazakhstan, is rich in underground mosques and khanakas, which are the reflection of Sufi culture in architecture. This region is considered a unique cultural landscape, where the most significant part of the country's monuments and holy places is concentrated. The underground mosques in Mangistau and Ustirt are unique in terms of historical and spiritual value. Excavation of shelters, places of worship, or “mortal abodes” by digging caves out of the common ground or mountain gorges has been a practice since very early times. Some of their samples are kept in Spain, Turkey, Jordan, and Crimea. The article analyzes the similarities and peculiarities of underground mosques with Sufi khanakas in the Middle Ages and their history and current use.