The city has two old medinas, the larger of which is Fes el Bali. It is listed as a UNESCO World Heritage Site and is believed to be one of the world's largest car-free urban areas. Al-Qarawiyyin, founded in AD 859, is the oldest continuously functioning madrasa in the world. The city has been called the "Mecca of the West" and the "Athens of Africa".
Until the Almoravid rule in the 11th century, Fes consisted of two separate cities or medinas: Madinat Fas and Al-'Aliya, the former being founded by Idris I, the latter by his son, Idris II. During Idrisid rule the capital city was known as Al-'Aliya, with the name Fas being reserved for the separate site on the other side of the river: no Idrisid coins have been found with the name Fes, only al-'Aliya and al-'Aliya Madinat Idris. It is not known whether the name al-'Aliya was ever used to refer to both medinas. It wasn't until 1070 that the two agglomerations were united and the name Fas was used for both sites.
The name is probably taken from the word Fazaz, the old Berber name for the Middle Atlas mountains near the city. The name is also attested as that of a Berber tribe living just south of Fes. Today, Ait Fazaz is the name of a small town just west of Meknes.
Foundation and the Idrisids
The city was founded on a bank of the Jawhar river by Idris I in 789, founder of the Zaydi Shi'ite Idrisid dynasty. His son, Idris II (808), built a settlement on the opposing river bank. These settlements would soon develop into two separate, walled and largely autonomous sites, often in conflict with one another: Madinat Fas and Al-'Aliya. In 808 Al-'Aliya replaced Walili as the capital of the Idrisids.
Arab emigration to Fez, including 800 Andalusi families of Berber descent in 817–818 expelled after a rebellion against the Umayyads of Córdoba, and 2,000 Arab families banned from Kairouan (modern Tunisia) after another rebellion in 824, gave the city a more Arabic character than other cities of the region. The Andalusians settled in Madinat Fas, while the Tunisians found their home in al-'Aliya. These two waves of immigrants would subsequently give their name to the two sites: 'Adwat Al-Andalus and 'Adwat al-Qarawiyyin. An important aspect of the city's population was of North-African Berber descent, with rural Berbers from the surrounding countryside settling the city throughout this early period, mainly in Madinat Fas (the Andalusian quarter) and later in Fes Jdid.
Upon the death of Idris II in 828, the dynasty’s territory was divided among his sons, and the eldest, Muhammad, received Fes. The newly fragmented Idrisid power would never again be reunified. During Yahya ibn Muhammad's rule in Fes the Kairouyine mosque, one of the oldest and largest in Africa, was built and its associated Al-Qarawiyyin Madrasa was founded (859). Comparatively little is known about Idrisid Fes, owing to the lack of comprehensive historical narratives from this period and the fact that little has survived of the architecture and infrastructure of early Fes (Al-'Aliya). The sources that mention Idrisid Fes, describe a rather rural one, not having the cultural sophistication of the important cities of Al-Andalus and Ifriqiya.
In the 10th century the city was contested by the Caliphate of Córdoba and the Fatimids of Tunisia, who ruled the city through a host of Zenata clients. The Fatimids took the city in 927 and expelled the Idrissids, after which their Miknasa were installed there. The Miknasa were driven out of Fes in 980 by the Maghrawa, their fellow Zenata, allies of the Caliphate of Córdoba. It was in this period that the great Andalusian ruler Al-Mansur Ibn Abi Aamir commissioned the Maghrawa to rebuild and refurnish the Al-Kairouan mosque, giving it much of its current appearance. According to the Rawd al-Qirtas and other Marinid era sources, the Maghrawi emir Dunas Al-Maghrawi filled up the open spaces between the two medinas and the banks of the river dividing them with new constructions. Thus, the two cities grew into each other, being now only separated by their city walls and the river flowing through them. His sons fortified the city to a great extent. This could not keep the Almoravid emir Ibn Tashfin from conquering the city in 1070, after more than a decade of battling the Zenata warriors in the area and constant besieging of the city.
Golden age and the Marinid period
Madinat Fas and Al-'Aliya were united in 1070 by the Almoravids: the walls dividing them were destroyed, bridges connecting the two parts were built and connecting walls were constructed that unified the medinas. Under Almoravid patronage the largest expansion and renovation of the Al-Kairouan mosque took place (1134-1143). Although the capital was moved to Marrakech and Tlemcen under the Almoravids, Fez acquired a reputation for Maliki legal scholarship and became an important centre of trade. Almoravid impact on the city's structure was such that the second Almoravid ruler, Ibn Tashfin, is often considered to be the second founder of Fes.
Like many Moroccan cities, Fes was greatly enlarged in the Almohad era and saw its previously dominating rural aspect lessen. This was accomplished partly by the settling there of Andalusians and the further improvement of the infrastructure. At the start of the 13th century they broke down the Idrisid city walls and constructed new ones, which covered a much wider space. These Almohad walls exist to this day as the outline of Fes el Bali. Under Almohad rule the city grew to become the largest city in the world between 1170 and 1180, with an estimated 200.000 people living there in that period.
In 1250 Fes regained its capital status under the Marinid dynasty. In 1276 they founded Fes Jdid, which they made their administrative and military centre. Fez reached its golden age in the Marinid period, which marked the beginning of an official, historical narrative for the city. It is from the Marinid period that Fes' reputation as an important intellectual centre largely dates. They established the first madrassas in the city and country. The principal monuments in the medina, the residences and public buildings, date from the Marinid period. The madrasas are a hallmark of Marinid architecture, with its striking blending of Andalusian and Almohad traditions. Between 1271 and 1357 seven madrassas were built in Fes, the style of which has come to be typical of Fassi architecture. The Jewish quarter of Fes, the Mellah was built in 1438, near the royal residence in Fes Jdid. The Mellah at first consisted of Jews from Fes el Bali, but soon saw the arrival of Berber Jews from the Atlas range and Jewish immigrants from Al-Andalus. The Marinids spread the cult of Idris I and encouraged sharifism, financing sharifian families as a way to legitimize their (in essence secular) rule: from the 14th century onwards hundreds of families throughout Morocco claimed descent from Idris I, especially in Fes and the Rif mountains. In this regard they can be seen as the enablers of the latter sharifian dynasties of Morocco. A revolt in 1465 overthrew the last Maranid sultan and in 1474 the Marinids were replaced by their relatives of the Wattasid dynasty, who faithfully (but for a large part unsuccessfully) continued Marinid policies.
In the Early Modern Age, the Ottoman Empire came close to Fez after the conquest of Oujda in the 16th century. In 1554, the Wattasid Dynasty took Fez with the support of the Turks, and the city became a vassal of the Ottomans, who finally conquered it in 1579 under sultan Murad III.
The Ottoman power in North Africa focused on threats posed by Habsburg Spain and the Portuguese Kingdom. As a result, Fez was not under pressure from the Ottoman rulers. The conquest of Fez was the catalyst for the move of the capital city of the Saadi Dynasty to Marrakech. Early in the 17th century the town returned to Moroccan control under Ahmad al-Mansur.
After the fall of the Saadi Dynasty (1649), Fez was a major trading post of the Barbary Coast of North Africa. Until the 19th century it was the only source of Fez hats (also known as the tarboosh). Then manufacturing began in France and Turkey as well. Originally, the dye for the hats came from a berry that was grown outside the city, known as the Turkish "kızılcık" or Greek "akenia" (Cornus mas). Fez was also the end of a north-south gold trading route from Timbuktu. Fez was also a prime manufacturing location for leather goods such as the Adarga.
The city became independent in 1790, under the leadership of Yazid (1790–1792) and later, of Abu´r-Rabi Sulayman. In 1795 control of the city returned to Morocco. Fez took part in a rebellion in 1819-1821, led by Ibrahim ibn Yazid, as well as in the 1832 rebellion led by Muhammad ibn Tayyib.
Fez was again the capital of Morocco until 1912. Rabat remained the capital even when Morocco achieved independence in 1956.
Despite the traditional character of most of the city, there is also a modern section, the Ville Nouvelle, or "New City". Today that is a bustling commercial center. The popularity of the city has increased since the King of Morocco took a computer engineer from Fes, Salma Bennani, as his wife.