Fez, the city of gates
In 789 AD, Moulay Idriss I settled on the left bank of the Oued Al Jawahir and purchased a parcel of land from the Ben Yazgha, a local Berber tribe, to found the city of Fez. The first buildings were erected on the Northern side of it near a very abundant spring called Ain Azliten. This is considered the oldest neighbourhood in Fez. Due to its geographical position overlooking the river from a height, Fez was initially called Al Alia—the height in Arabic. The city was founded to host the neophyte refugees from Qairawan, who settled on the left bank of the river. Later, the neophyte refugees from Andalusia settled on the right side of the river. Even today, the Old Medina is divided into distinguished districts, such as Al Qaraouiyyine and the Andaluz.
The city was initially unwalled, with a central gate Located North at Ain Azliten and the Gate of Bani Msafer to the south for the Andalus district. Fez was first walled in the late 8th or early 9th century. The city was founded around 789 AD by Idris I and subsequently expanded by his son, Idris II, in 808. The initial walls were built to protect the early settlement, but the most famous fortifications came later under the Almoravid and Almohad dynasties in the 11th and 12th centuries. The fortifications gave birth to numerous gated communities, some of which still exist today. Traditionally, these gates used to close every night at sunset and open after dawn prayer. These gates served to facilitate trade and keep the intruders out.
The 13 major gates of the Medina:

Bab Bou Jeloud (The Blue Gate) • Built: 1913 by the French colonial administration • Features: Notable for its blue and green zellij tilework, symbolizing Fez and Islam respectively • Significance: Serves as the main western entrance to the medina, leading to the bustling Tala'a Kebira and Tala'a Sghira streets • Historical Note: Adjacent to the original, more modest gate with a bent entrance

Bab Mahrouk (Gate of the Burnt) • Built: 1204 under Almohad ruler Muhammad al-Nasir • Original Name: Bab ash-Shari'a ("Gate of Justice") • Historical Significance: Renamed after the execution and burning of the rebel al-'Ubaydi in 1203–04; historically used to display the heads of executed rebels

Bab Ftouh (Gate of Conquests) • Historical Importance: One of the oldest gates, serving as a key entrance to the southeastern part of the medina, is named after a holy man called Sidi Ftouh, who is buried on the right side of the gate. • Adjacent Site: Bab Ftouh Cemetery, one of Fez's largest and most prestigious cemeteries, housing graves of notable citizens and saints

Bab Guissa • Era: Dates back to the Almohad period (12th–13th century) • Design: Features a bent entrance with a 90-degree turn; a side gate was later added for easier access • Nearby Landmark: Adjacent to the Bab Guissa Mosque, built in the 14th century during the Marinid dynasty

Bab el-Hadid (Iron Gate) • Location: Situated in the southwestern part of the city walls • Historical Context: Before the 20th century, the area was less developed, primarily consisting of gardens and mansions

Bab Jdid (New Gate) • Function: Provides access to the central medina; not historically a major gate but now serves as a key entry point.
Bab Sidi Bou Jida • Historical Names: Previously known as Bab Abi Soufine and Bab Bani Msafer • Current Name Origin: Named after the nearby Sidi Boujida mausoleum, a site favored by students and women seeking blessings • Current State: The gate is affected by surrounding market congestion and structural cracks.

Bab Chorfa (Gate of the Sharifs) • Restoration: Restored in the 18th century by Sultan Moulay Slimane • Architectural Features: Comprises a single arch flanked by two towers • Access Point: Serves as the entrance to Kasbah An-Nouar, a historic walled district
**
Bab Chems (Bab Shams)**
Meaning "Gate of the Sun," this gateway is located at the western end of Place Bou Jeloud and was probably first opened in the late 19th century.
Bab el-Hamra Once located west of Bab Ftouh, this gate had already disappeared by the 16th century, with its name preserved through the Bab al-Hamra Cemetery.
Bab Khoukha (Bab Knisa) Situated at the eastern/southeastern end of the city, this gate had disappeared by the 16th century, leaving only its name as a toponym in the area.
Bab Ziat One of the few gates that provide access to Medina traffic is located near the Ziat district.
Bab Ain Azliten (Gate of the Azliten Spring, the oldest in Fez) • Historical Background: Bab Ain Azliten served as the entrance to the Ain Azliten district, one of the oldest neighborhoods in Fes Medina. This area dates back to the Zenata period, spanning the 10th and 11th centuries. The district and the gate derive their name from the Azliten, a Berber tribe that settled in the region during that era.
• Current Status: Unfortunately, the original structure of Bab Ain Azliten has since been demolished. It was demolished to make way for a road leading to Tala'a Kebira Street. Today, only small remnants of the gate remain on the sides of the road, serving as silent witnesses to its historical significance.
• Cultural Significance: The Ain Azliten district remains a vibrant part of the medina. Notably, it houses the Ain Azliten Tannery, one of the traditional tanneries in Fez, providing visitors with a glimpse into the city's renowned leatherworking heritage.