Medersas – student colleges and residence halls – were by no means unique to Fez. Indeed, they originated in Khorasan in northeastern Iran and gradually spread west through Baghdad and Cairo, where the Medersa al Azhar was founded in 972 AD and became the most important teaching institution in the Muslim world. They seem to have reached Morocco under the Almohads, although the earliest ones still surviving in Fez are Merenid, dating from the late thirteenth century.
The word medersa means “place of study”, and there may have been lectures delivered in some of the prayer halls. However, most medersas served as little more than dormitories, providing room and board to poor (male) students from the countryside, so that they could attend lessons at the mosques. In Fez, where students might attend the Kairaouine University for ten years or more, rooms were always in great demand and “key money” was often paid by the new occupant. Although medersas had largely disappeared from most of the Islamic world by the late Middle Ages, the majority of those in Fez remained in use right up into the 1950s. Non-Muslims were not allowed into the medersas until the French undertook their repair at the beginning of the Protectorate, and were banned again (this time by the colonial authorities) when the Kairaouine students became active in the struggle for independence.
Since then, restoration work, partly funded by UNESCO, has made medersas more accessible, although it will still be some while before all the work is complete – at the time of writing, for example, the Medersa es Seffarine and the Medersa es Sahrija were both closed for renovation. As restoration across the city continues, accessibility is impossible to predict.