Sufism developed as an aesthetic movement in the 8th and 9th centuries in Iran, Iraq, Syria, and Egypt. Its adherents were committed to a life of poverty and to meditation. During the Seljuk Turk Dynasty, Sufis became organized into fraternities and built lodges, called khānaqāh, in Persian, that functioned as hospice centers for Sufi travelers and centers of meditation and retreat. These lodges were often located next to schools, called madrasas, or mosques.
The sultans who ruled during this era had taken over without religious legitimacy, and their connection to Sufism provided them with religious authority. Sufis, long connected with the community, were able to help the sultans gain legitimacy with the populations over which they ruled. Sufism, guided by the philosophy of Ibn al-Arabi (1165–1240), focused on the ethical dimensions of being what Ibn al-Arabi called a "perfect man." Sufis were tolerant of a range of religious practices, including wandering dervishes, and their ethical and religious practices provided a great deal of stability and legitimacy for rulers in India, southeast Asia, and sub-Saharan Africa.