The history of religious schools in Egypt cannot be separated from the history of politics, as the school was established to serve the sect according to the direction of the ruling authority in it. The historian Taqi al-Din Ahmad ibn Ali al-Maqrizi listed at least 30 schools established by the Ayyubids and Mamluks, some of which still exist today.

Schools were concentrated in the courtyard of Al-Azhar Mosque through corridors for different sects and the four sects, such as the gallery of Upper Egypt and Manaifeh.