Al‑Qarawiyyin Mosque: A Historical & Scientific Landmark in Fez
The gates and social history of Al-Qarawiyyin Mosque in Fez, Morocco, reveal a rich legacy of religious, educational, and humanitarian values. Each gate served not only as an architectural entry point but also played a role in shaping the mosque’s societal and cultural function over the centuries.
While the scientific reputation of gates and social history of Al-Qarawiyyin Mosque has been extensively celebrated, its profound social and economic contributions—both within its surroundings and beyond its campus—have often been overshadowed. These contributions, however, are still visible today in the civilizational legacy that endures in various aspects of Moroccan society.
Gates and social history of Al-Qarawiyyin Mosque is typically referenced in the context of its historic scholarly role and the distinguished figures who studied or taught there, whether from Morocco, the Islamic East, Andalusia, or across North and West Africa. Many books, articles, and academic studies are filled with the names of these luminaries. Just as contemporary Moroccan students travel to European institutions in search of knowledge, European students once journeyed to Fez to study at Al-Qarawiyyin.
Had history not preserved the story of Gerbert von Aurillac—who would later become Pope Sylvester II—we might never have known that he was one of many European students who received their education at Gates and social history of Al-Qarawiyyin Mosque, He remains the only Pope known to have studied Arabic and mastered the sciences of the Islamic world. Thanks to him, Europe was introduced to Arabic numerals, arithmetic, mathematics, astronomy, and the astrolabe. His enthusiasm for Arabic numerals was so profound that he employed them metaphorically in a letter to Emperor Otto, his assistant in scholarly exploration of the Islamic West. In the letter, he wrote: “I liken you to the last of the ten simple numbers, whose value increases by placing other numbers to its left”—a poetic reference to the zero.
Europe is also indebted to him for introducing Islamic jurisprudence into its legal framework, using it to develop and refine Roman legal codes. The commonalities observed today between Islamic and European legal systems are not accidental, nor do they suggest that Islamic jurisprudence was influenced by Europe. On the contrary, it was Islamic law that played a formative role in shaping aspects of European legal tradition—despite contrary claims, such as those by the Hungarian-Jewish orientalist Ignaz Goldziher (1850–1921).
As Moroccan philosopher Mohammed Abed al-Jabri once stated: “If Greek civilization was a civilization of reason, and modern civilization one of material science, then Islamic civilization is a civilization of jurisprudence—of law.” No civilization prior to Islam developed such a comprehensive legal system regulating both material and spiritual life from cradle to grave.
The University of Al-Qarawiyyin welcomed scholars from all faiths and sects. Among them was the renowned Jewish philosopher Maimonides, of whom it is said: “No one came in science after the Prophet Moses except Moses.” The institution also nurtured the intellects of Ibn Bajjah, Ibn Arabi, Ibn Zuhr, Al-Idrisi, Ibn Khaldun, Ibn al-Khatib, the anti-colonial leader Abd al-Karim al-Khattabi, and many others.
Moreover, Gates and social history of Gates and Social History of Al-Qarawiyyin Mosque: A Window into Fez’s Past, stands as a monument to women’s intellectual heritage—it was founded by a visionary woman from Kairouan, Fatima al-Fihri, whose contribution is immortalized in the very fabric of Moroccan scholarly identity.
Unfortunately, discussions of gates and social history of Al-Qarawiyyin Mosque are often reduced to tourist clichés—disputes over the exact date of its foundation or repetitive, unreliable statistics about its 14 gates, 260 columns, or capacity of 20,000 worshipers. Ironically, guidebooks published in Western countries often provide more accurate historical information than many local guides, whose narratives tend to focus on these dubious figures. In fact, historians such as Ibn Abi Zar’, Al-Jazna’i, Leo Africanus (Ibn al-Wazzan), and the author of Al-Anis al-Mutrib have long debated the mosque’s architectural specifics.
The religious and political history of Morocco is deeply intertwined with Medina. Moroccans follow the Maliki school of jurisprudence, named after Imam Malik ibn Anas of Medina. Their Quranic recitation is from Warsh, a student of Nafi‘, one of the seven canonical reciters from Medina. The founder of Fez and the first independent Moroccan state—Idris I—was a descendant of the Prophet Muhammad and played a pivotal role in establishing the religious and political identity of the region.
Al-Qarawiyyin University was established under the reign of Idris’s son, Yahya, more than a century before Cairo’s Al-Azhar University, and some 300 years before Europe’s oldest universities—Bologna, the Sorbonne, and Oxford. As the Russian orientalist Yevgeny Kratchkovsky once noted: “The oldest college in the world is not in Europe, as we used to believe, but in Africa, in Fez, the capital of Morocco.”
Over the centuries, the architecture of the university and its mosque has undergone numerous expansions and renovations, as evidenced by its 17 distinct doors—each bearing witness to a historical period, a political event, or a social function tied to the legacy of this grand institution.
Bab al-Hafa
Bab al-Hafa: A Story from the gates and social history of Al-Qarawiyyin Mosque is the oldest gate of the Al-Qarawiyyin Mosque and stands as a testament to the historic relationship between the mosque and the poorer classes of society. The name “Bab al-Hafa” literally means “The Gate of the Barefoot,” referring to those who could not afford shoes. It was through this gate that the barefoot entered, washing their feet in a rectangular lead-covered channel—an addition attributed to Al-Muzaffar al-Amiri, the second ruler of the Al-Amiri dynasty in Andalusia. This symbolic gesture ensured that even the most humble members of society had access to this revered place of worship and learning, whether to pray or to attend lessons.
A similar gate exists at the Al-Andalus Mosque, reflecting a broader cultural value of inclusiveness in Islamic architecture and social policy.
Al-Qarawiyyin’s long history is deeply rooted in social solidarity, and this is evident in its system of endowments (awqaf). To the right of Bab al-Hafa, near the public water fountain—designed so that everyone in the Boutouil district could have access to clean water—stood a pottery shop endowed for the benefit of children and household servants. Whether working in artisan workshops or in homes, if a child or servant accidentally broke a ceramic vessel, the shop would replace it at no cost using funds from the endowment. This ensured they would not be punished by their guardians or employers. Several such charitable shops existed across the city of Fez.
Adjacent to this area, on the western side of the mosque, was a smaller gate known as Bab al-Majlis al-ʿIlmi (The Gate of the Scientific Council). This door led to the section of the mosque dedicated to issuing fatwas and recording legal testimonies—another reflection of Al-Qarawiyyin’s role not only as a center of religious learning but also as a civic and legal authority.
Bab al-‘Udul (The Door of the Notaries)
This is one of the oldest gates of the Al-Qarawiyyin Mosque, second only to Bab al-Hafa (the Door of the Barefoot). Opposite it were the shops of the notaries, which gave the gate its name. It is also known as Bab al-Shuhada’ (the Door of Witnesses), due to the frequent activity related to legal documentation and judicial testimonies that took place in its vicinity. This street was commonly used by notaries because of its proximity to both the public and the court.
- Bab al-Shamāʿīn (The Door of the Candles)
This gate dates back to the reign of Emir Ali ibn Yusuf ibn Tashfin and serves as the main entrance to the Al-Qarawiyyin Mosque. It is known by several names:
- Bab al-Najjārin (The Door of the Carpenters), as cited by the author of Al-Istibsar, due to the nearby carpentry shops.Bab al-Shahīd (The Door of the Martyr), referencing the martyrdom of Imam Abd al-Wahid al-Wansharisi (1475–1548), who was killed here after leading the opposition to the ratification of the Saadian allegiance.
The gate also faces a market where candles were traditionally sold, alongside dried fruits—many of which are still sold there today. This is why it came to be known as Bab al-Shamāʿīn (The Door of the Candlemakers).
Notably, this door faces the astronomical tower, which houses mechanical water clocks and devices used to monitor the movements of stars and regulate planetary cycles.
Bab al-Warraqīn (The Door of the Stationers)
This gate dates back to the final years of the Almohad dynasty and was also known as Bab al-Kutubiyyīn (The Door of the Booksellers), as the shops that lined the area were dedicated to selling writing materials, books, and offering manuscript copying services.
The book and paper industry was introduced to Fez in the 12th century, arriving from the East via Tripoli. It quickly established itself around Al-Qarawiyyin, from where it later influenced book trade and learning in Europe. The famous traveler Hassan al-Wazzan (Leo Africanus) mentioned that there were around thirty bookshops in this area.
Over time, many of these shops transitioned into notary offices, and the gate later also became known as Bab al-‘Udul (The Door of the Notaries).
One notable social function associated with this gate involved an Egyptian woman known as “Masriyat al-Hajja”, who provided housing for gifted students near the gate. Lost items were deposited there during the week, and after Friday prayers, announcements about found objects were made at Bab al-Salihin.
Bab al-Awliya (The Door of the Saints)
This gate was named after the saints (awliya) due to a tradition observed in earlier times: many righteous and pious men who visited Al-Qarawiyyin from the west would enter through this door. If they arrived from the east, they would use a gate directly opposite.
As noted by Dr. Abdelhadi Tazi in his book Al-Qarawiyyin, “I have no explanation for that”—highlighting this phenomenon as a curious yet unexplained tradition rooted in the spiritual habits of the past.
Bab al-Nata’in (The Gate of the Leather Rugs)
Among the most symbolic Gates of Al-Qarawiyyin Mosque is Bab al-Nata’in, which opens onto the traditional leather market. The term na‘ta’ refers to a leather rug, and this gate opens onto the leather market. Leather played a crucial role in book production—used for bookbinding, design, and gilding. From this, the Arabic term for large, valuable books—mujalladāt (volumes)—emerged.
This gate is also known as Bab al-Sbitriyyin, a name brought by Andalusian immigrants. It derives from the Spanish word zapatero (shoemaker). Over time, leatherworkers (al-kharraza) occupied the area, and it became associated with their craft.
Additionally, the gate is called Bab al-Safra al-‘Ulā due to being one of the three gates of the Al-Qarawiyyin Mosque adorned with yellow brass plating.
Bab al-Khulafā’ (The Gate of the Caliphs)
This gate was opened in 531 AH / 1137 CE, during the final years of the Almoravid dynasty. It was known as the Gate of Royal Decrees, used exclusively by the caliph and his entourage when attending Friday prayers.
Upon arrival, the caliph would be ceremonially greeted with dates and milk. This gate was deliberately chosen because it leads directly, through a small courtyard, to the mihrab (imam’s chamber), where the caliph would wait before prayer. A similar ceremonial gate exists in the Great Mosque of Córdoba.
The Gate of the Judiciary Council (Bab Majlis al-Qadā’)
This gate was constructed during the Almoravid expansion of the mosque and is also known as the Gate of the Funeral Mosque because it leads to an annexed mosque designated for funeral prayers.
The funeral mosque was built to resolve a jurisprudential debate on the purity of the deceased. Such funeral mosques are rare in Morocco and almost unknown in the Islamic East—except for one in the Umayyad Mosque of Damascus. The Seville Mosque also had a funeral mosque, according to the historian Ibn ‘Abdun.
This gate is sometimes referred to as Bab al-Kutub (Gate of the Books), as this annex hosted a Sunday book market until relatively recent times. The name Gate of the Judiciary Council originates from the judge’s platform (minbar al-qādī) formerly located to the left of the gate.
Bab al-Farkha (The Discreet Gate)
This is a small, discreet gate used by mosque assistants when needed as a service or back entrance. The name farkha (lit. “key”) may allude to the hidden access it provided.
It lies beneath a covered passageway (sabat) between two walls and is also called the Gate of Concealment (Bab al-Tastur), due to its social role. It was designed to protect the privacy of litigants—both men and women—who were required to take oaths, ensuring they entered unseen and with dignity.
Bab al-Hadoudi
Located behind the Al-Qarawiyyin Library, this gate connects the library to the mosque. The basement beneath what is now the Abu Inan Library—built in 1349 CE by Sultan Abu Inan al-Marini—once served an economic and financial function.
It housed one of the world’s earliest banking systems, predating the oldest still-operating modern bank, Monte dei Paschi di Siena (1472), as well as the Bank of Venice (1587) and the Bank of Amsterdam (1609).
The Al-Qarawiyyin Endowments (awqāf) amassed such wealth through donations that a secure treasury became essential. A strong vault was constructed beneath the portico, complete with reinforced walls and flooring. Access required three separate keys, each held by a different trustee, ensuring that no one person could open it alone.
Well-constructed chests and locks stored the endowment wealth, attracting merchants and nobles to deposit their assets there, confident in its security. The treasury continued to operate for many years.
Nearby, at Bab al-Qaysariyyah, shops tied to the mosque’s endowments were used to distribute loans to the needy, a practice confirmed by scholars such as the commentator on Tuhfat Ibn Asim, who wrote:
“Entrustment is permissible, both in essence and in kind—meaning advances (loans).”
Not far from Bab al-Hadoudi, near Tariq al-Wafa’ al-Sab‘a (The Road of the Seven Loyalties), stood a public oven, whose proceeds were managed by the local judge and distributed to the poor. This is said to be the oldest oven in Fez, even predating Al-Qarawiyyin itself.
Darb al-Ratoun – Dar al-‘Āfiyah (The House of Grace)
A few meters away from this oven lies Darb al-Ratoun, a building with three floors. One floor was fully furnished and prepared to host newlyweds, especially those of noble or modest background who could not afford wedding expenses.
Couples were allowed to stay free of charge for two weeks after their wedding. The house is traditionally called Dar al-‘Āfiyah (“The House of Well-Being”), in hopes of a blessed beginning for the newly married.
Three such houses for brides once existed in the Adwat al-Qarawiyyin district; this is one of them. It was endowed by the philanthropist Abd al-Malik ibn Hayoun, who died in 599 AH / 1202 CE. Two similar homes were located in Adwat al-Andalus.
Bab al-Khalwa (The Gate of Seclusion)
This gate is higher than all the other external gates of Al-Qarawiyyin, accessed by nine steps. It became known as Bab al-Khalwa because a Qur’anic retreat corner (khalwa) was later built nearby. It dates back to the Almoravid expansion of the mosque.
Opposite this gate, slightly to the left, stood a large residence known as Dar al-Nisā’ (The House of Women). It was a refuge for women who had suffered violence at the hands of their husbands. Managed by a female leader, a woman seeking refuge could only leave after a legal commitment from her husband, witnessed officially, stating he would no longer use violence.
All expenses—lodging, food, and supervision—were covered by village endowment funds. This institution preceded by centuries the concept of women’s shelters common in modern European cities.
Bab al-Sāliḥīn al-Sharqī (Eastern Gate of the Righteous)
This gate faces Bab al-Awliyā’ on the western side and leads to Sāḥat al-Haram al-Kabīr (Court of the Great Pyramid). Historian Dr. Abdelhadi al-Tazi noted seeing judicial documents from the time of Sultan Moulay Ismail, indicating the gate existed as early as 1115 AH / 1703 CE and was still referred to then as Bab al-Sāliḥīn.
A nearby path bears the name Bab Sab‘a Louāyāt (Gate of the Seven Loyalties).
Bab Ibn Ḥayyūn
Named after the Andalusian philanthropist Abd al-Malik Ibn Ḥayyūn, whose name is still preserved in the nearby street. A public hammam (bathhouse) was located within this street to provide easy access to purification for students and teachers living around the mosque.
Ibn Ḥayyūn’s humanitarian work included donating two-thirds of his wealth to prisoners, and the remaining third to the poor. When prices rose significantly, his will was amended so that all the funds were redirected to support the poor.
Opposite the gate stands a small inn known as Hotel Abdul Majid, once home to the scholar Abdul Majid al-Bādīsī, who passed away in 1004 AH. The hotel also had a notable social function: it was known as the “Breastfeeding Hotel.” Women who produced abundant breast milk were housed there and were entrusted with nursing orphaned infants or children whose mothers could no longer breastfeed. They were compensated by the Al-Qarawiyyin Endowment Administration, and every nursing contract was officially recorded by two notaries.
Bab Ibn ‘Umar
This gate was built during the Almohad era and later renovated under the Marinid dynasty. Opposite it stood a hotel used by merchants from Tétouan, named after the carpenter ‘Umar, who built it and donated part of his work to the mosque.
This gate was constructed seventy years after its counterpart on the western side.
Bab al-Sabāt
A small, unassuming gate—the first on the northern side of the mosque. Women used this entrance to reach the upper hallway designated for them. It is located above the storage room and directly across from the house reserved for the imams.
Bab al-Khāṣṣa
One of the oldest gates of the mosque, predating even the construction of al-Khāṣṣa (private area), which was built in 599 AH / 1203 CE, during the Zenata period.
Bab al-Ṣafrā’ al-Shamālī (Northern Yellow Gate)
This gate earned its name due to being covered in yellow brass. It was also known as:
- Bab al-‘Umyān (Gate of the Blind) because of the frequent presence of blind people at this gate.
- Bab al-Ward (Gate of Roses), named after an incident where a pious man tied his horse there. Upon returning, he found people rebuking the horse owner for leaving behind waste near the mosque’s gate. Moved by the criticism, he vowed to rebuild the gate. Instead of using regular water in the construction materials, he used rose water, out of reverence for the mosque. From that day, it has been called Bab al-Ward.
Humanitarian and Social Landmarks Around Al-Qarawiyyin
Beyond architecture, Al-Qarawiyyin’s surroundings were deeply rooted in social care and compassion:
- Animal welfare: A portion of the mosque’s endowments was devoted to purchasing grain to feed birds, especially during times of food scarcity. The grains were scattered in Jabal al-Tuyūr (Birds’ Hill) near Bab Ftouh and Bab Ajīsā.
- Nightly Comfort for the Ill: Some endowments were assigned to muezzins who recited comforting chants and supplications from the mosque’s minaret during the night for the sleepless and the sick. This noble duty was called “Ṣāḥib al-Gharīb” (Companion of the Stranger).
- Cooling the Courtyard: Long before electric fans, manual air-conditioning systems were used—fabric shades with strategically cut holes tied to ropes. When pulled, these ropes created airflow, similar to the techniques used in Baghdad, according to historical accounts.
- Night Classes: Al-Qarawiyyin offered night lectures long before this practice became common in Europe. Specialized professors taught evening sessions after the ‘Ishā’ prayer for those unable to study during the day, continuing until dawn.
Al-Nabarīn Mosque – A Center of Consultation
Located in Raḥbat Banī Qays, this mosque—Masjid al-Nabarīn—derives its name from the word nabra, meaning “prominence” or “clarity.”
One of the oldest mosques in Adwat al-Qarawiyyin, it functioned as a civic advisory center. Experts in various fields gathered to assist residents with social, marital, and commercial issues, though it did not handle religious jurisprudence, which was reserved for formal courts.
Learn more about the architectural heritage of historic Moroccan mosques.