# History of Fez

The History of Fez begins with its foundation by Idris I and Idris II at the end of the 8th century and the beginning of the 9th century CE. It initially consisted of two autonomous and competing settlements on opposing shores of what is now known as the Oued Fes. Initially inhabited by a largely Berber (Amazigh) population, successive waves of mainly Arab immigrants from Ifriqiya (Tunisia) and al-Andalus (Spain/Portugal) over time gave the nascent city an Arab character as well. After the downfall of the Idrisid dynasty, it was contested between different Zenata groups allied with either the Fatimid Caliphate or the Umayyad Caliphate of Cordoba. In the 11th century the Almoravid sultan Yusuf ibn Tashfin conquered the region and united its two settlements into what is today the Fes el-Bali ("Old Fez") quarter. Under the rule of the Almoravids and of the Almohads after them, despite losing the status of capital to Marrakesh, the city remained the economic and political center of northern Morocco and gained a reputation for religious scholarship and mercantile activity.
Fez reached its zenith in the Marinid era (13th-15th centuries), regaining its status as political capital. In 1276 the Marinid sultan Abu Yusuf Yaqub also founded a separate royal city, Fes el-Jdid ("New Fes"), just west of Fes el-Bali, where the royal palace is still located today. Numerous new madrasas and mosques were constructed across Fez, many of which survive today, while other structures were restored. During this period the Jewish population of the city grew and the Mellah (Jewish quarter) was formed on the south side of this new district. After the overthrow of the Marinid dynasty, Fez underwent periods of decline and prosperity and often competed with Marrakesh for political and cultural influence. The city rose again in influence during the 19th century and remained the capital of the Alaouite sultanate until 1912, when it came under control of the French Protectorate in Morocco. The French colonial regime moved the capital to Rabat, where it remains today, and Fes underwent a political decline. The French also constructed a new city, the Ville Nouvelle, to the southwest, which grew into what is now most of the modern city of Fez.

## Foundation under the Idrisids (7th-8th centuries)

The city was first founded in 789 as Madinat Fas on the southeast bank of the Jawhar River (now known as the Fez River) by Idris I, founder of the Idrisid dynasty. His son, Idris II, built a settlement called Al-'Aliya on the opposing river bank in 809 and moved his capital here from Walili (Volubilis).$^{:35}$$^{:35}$$^{:83}$ These settlements (Madinat Fas and Al-'Aliya) would soon develop into two walled and largely autonomous sites, often in conflict with one another. The early population was composed mostly of Berbers, along with hundreds of Arab warriors from Kairouan who made up Idris II's entourage.
Arab emigration to Fez increased afterwards, including Andalusi families of mixed Arab and Iberian descent who were expelled from Córdoba in 817–818 after a rebellion against the Al-Hakam I$^{:46}$ as well as Arab families banned from Kairouan (modern Tunisia) after another rebellion in 824. The Andalusians mainly settled in Madinat Fas, while the Tunisians found their home in Al-'Aliya. These two waves of immigrants gave the city its Arabic character and would subsequently give their name to the districts of 'Adwat Al-Andalus and 'Adwat al-Qarawiyyin.$^{:51}$ With the influx of Arabic-speaking Andalusians and Tunisians, the majority of the population was Arab, but rural Berbers from the surrounding countryside settled there throughout this early period, mainly in Madinat Fas (the Andalusian quarter) and later in Fes Jdid during the Marinid period. The city also had a strong Jewish community, probably consisting of Zenata Berbers who had previously converted to Judaism, as well as a small remaining Christian population for a time. The Jews were especially concentrated in a northeastern district of Al-'Aliya known as Funduq el-Yihoudi (near the later Bab Guissa).$^{:42–44}$
The area benefitted from abundant water, and each of the two settlements was fully equipped with its own urban amenities. The first mosques of the city were the Mosque of the Sharifs (or Shurafa Mosque) and the Mosque of the Sheikhs (or al-Anouar Mosque); however, they no longer exist in their original form. The Mosque of the Sharifs became the burial site of Idris II upon his death and later evolved into the Zawiya of Moulay Idris II that exists today, while the al-Anouar Mosque has left only minor remnants. According to one of the major early sources on this period, the Rawd al-Qirtas by Ibn Abi Zar, in 859 the Al-Qarawiyyin Mosque ("Mosque of the people from Kairouan') was founded by Fatima al-Fihri, the daughter of a wealthy merchant. Her sister, Mariam, is likewise reputed to have founded the Al-Andalusiyyin Mosque ('Mosque of the Andalusians') the same year.
Upon the death of Idris II in 828, the dynasty's territory was divided among his sons. The eldest, Muhammad, received Fez, but some of his brothers attempted to break away from his leadership, resulting in an internecine conflict. Although the Idrisid realm was eventually reunified and enjoyed a period of peace under Ali ibn Muhammad and Yahya ibn Muhammad, it fell into decline again in the late 9th century.

## Zenata domination and imperial rivalries (10th-11th centuries)

In the 10th century, the city was contested by the Umayyad Caliphate of Córdoba and the Fatimid Caliphate of Ifriqiya (Tunisia), who ruled the city through a host of Zenata clients. The Fatimids took the city in 927 and expelled the Idrisids definitively, after which their Miknasa (one of the Zenata tribes) were installed there. The city, along with much of northern Morocco, continued to change hands between the proxies of Córdoba and the proxies of the Fatimids for many decades. Following another successful but ephemeral Fatimid takeover of Morocco in 979 by Buluggin ibn Ziri, the forces of Al-Mansur of Córdoba managed to retake the region again, expelling the Fatimids permanently.
Despite the political instability of this era, notable contributions to the city's development were made. In 956 the Qarawiyyin Mosque was significantly expanded by the local Zenata governor, Ahmed ibn Abi Said, with funds provided by Abd al-Rahman III of Córdoba. At the same time, both the Qarawiyyin Mosque and the Andalusiyyin Mosque were given new minarets, which appeared to be simplified versions of the minaret Abd al-Rahman III built for the Great Mosque of Córdoba during the same decade.$^{:62}$
From 980 (or from 986), Fez was ruled by a Zenata dynasty from the Maghrawa tribe, who were allies of the Caliphate of Córdoba. They maintained this control even after the Caliphate's collapse in the early 11th century and until the arrival of the Almoravids.$^{:16}$$^{:91}$ Under Zenata control Fez continued to grow even though conflicts between its two settlements, Madinat Fas and Al-'Aliya, flared up during periods of political rivalry. Ziri ibn Atiyya, the first ruler of the new dynasty, had a troubled reign. However, Ibn Atiyya's descendant Dunas Ibn Hamama, ruling between 1037 and 1049, was responsible for many important infrastructural works necessary to accommodate Fez's growing population. He developed much of Fez's water distribution infrastructure, which has largely survived up to the present day. According to the tenth-century geographer, Ibn Hawqal, water was flushed into the suqs every summer night to clean the ground. The water was also transported to public baths and 300 mills. The city grew quickly and by the late 900s, it had about 100,000 inhabitants.
Other structures built in his time included hammams (bathhouses), mosques, and the first bridges over the Oued Bou Khrareb (mostly rebuilt in later eras). Thus, the two cities became increasingly integrated into each other: the open space between the two was increasingly filled up by new houses and up to six bridges across the river allowed for easier traffic between the two shores.$^{:36}$ A decade after Dunas, however, between 1059 and 1061, the two opposing settlements of the city were ruled separately by two rival Zenata emirs: Al-'Aliya was controlled by an emir named 'Ajisa and Madinat Fas was controlled by his brother el-Ftouh. Both brothers fortified their respective shores, and their names have been preserved in two of the city's gates to this day: Bab Guissa in the north and Bab Ftouh in the south.$^{:50}$ In 1062, the Hammadid emir Buluggin ibn Muhammad led an expedition against the Maghrawa and briefly captured Fez for several months before leaving. He was subsequently assassinated on his return journey eastward and Fez returned to Maghrawa control afterward.$^{:43–49}$

## Fez under the Almoravids and Almohads (11th-13th centuries)

The Almoravids, who originated far to the south, advanced into the region near Fez in the early 1060s. In 1063, under the leadership of Yusuf Ibn Tashfin, they began a long military conquest of the region in order to defeat the Maghrawa, who were the main resistance to their rule. The last Maghrawa ruler of Fez, Mu'ansir Ibn Ziri, was a persistent obstacle.$^{:43–49}$ Unable to take Fez quickly, Ibn Tashfin conquered some of the surrounding forts and settlements first before refocusing on besieging the city. Mu'ansir fled Fez before the Almoravids were able to capture it in the later months of 1063.$^{:46}$ Ibn Tashfin appointed a member of his tribe as governor of the city and left a garrison of 400 Lamtuna tribesmen to guard it, then set out on further campaigns across northern Morocco. In his absence, Ibn Ziri returned, recaptured the city after a siege, and killed Ibn Tashfin's governor. The Almoravids retaliated by besieging the city and setting up a blockade. Eventually, Ibn Ziri was killed in a sortie against them, but the local Zenata continued to resist and rallied around a new leader, a man of noble lineage from Taza named Qasim Ibn Abd al-Rahman. Still unable to take the city, Ibn Tashfin kept the pressure on but chose instead to resume his conquest of the surrounding countryside and of northern Morocco, so as to eliminate resistance outside the city first. This took occupied him from 1064 until 1070.$^{:43–49}$
Ibn Tashfin finally captured the city definitively on 18 March 1070 (462 AH).$^{:49}$ (Other sources give the date as 1069.$^{:51}$$^{:82}$) There is some contradiction and uncertainty in historical sources, however, and some historians date the final conquest to 1074 or 1075.$^{:39,337}$$^{:110}$ The Almoravids sacked the city and massacred many of the Zenata, although it seems that Fez itself did not suffer much long-term damage.$^{:49}$$^{:51–52}$ In the same year of this conquest, Ibn Tashfin finally unified Madinat Fas and Al-'Aliya into one city.$^{:51–52}$ The walls dividing them were destroyed, bridges connecting them were built or renovated, and a new circuit of walls was constructed that encompassed both cities. A kasbah (citadel), later known as the Kasbah Bou Jeloud, was built at the western edge of the city (just west of Bab Bou Jeloud today) to house the city's governor and garrison.$^{:50–51}$ With the help of engineers from Cordoba, Ibn Tashfin also upgraded the city's water supply system by creating additional canals branching off from the main canals made earlier by Dunas Ibn Hamama. Under the patronage of the later Almoravid emir Ali Ibn Yusuf the largest expansion and renovation of the Great Mosque of al-Qarawiyyin took place between 1134 and 1143.$^{:20}$ Although the capital was moved to Marrakesh under the Almoravids, Fez acquired a reputation for Maliki legal scholarship and remained an important centre of trade and industry. Almoravid impact on the city's structure was such that Yusuf Ibn Tashfin is sometimes considered to be the second founder of Fez.$^{:51}$
In 1145 or 1146 the Almohad leader Abd al-Mu'min besieged and conquered the city during the Almohad overthrow of the Almoravids.$^{:54–55}$$^{:71–72}$ The city, led by the Almoravid governor Yahya Ibn al-Sahrawiyya, resisted fiercely and the city was only taken after a hard siege during which the Almohads cut off the city's water supply. The besiegers finally entered the city with the help of 'Abdallah Ibn Khiyyar al-Jayyani, the local Almoravid financial administrator (mushrif), who switched his allegiance and opened the gates to them.$^{:72}$ Due to the ferocious resistance they encountered, the victorious Almohads retaliated by demolishing the city's fortifications, massacring most of the Almoravids, and destroying many houses.$^{:54–55}$$^{:72}$
However, due to Fez's continuing economic and military importance the Almohad caliph Ya'qub al-Mansur later ordered the reconstruction of the ramparts.$^{:36}$$^{:606}$ Since the city had grown in the meantime, the new Almohad perimeter of walls was larger than that of the former Almoravid ramparts.$^{:607}$ The walls were completed by his successor Muhammad al-Nasir in 1204, giving them their definitive shape and establishing the perimeter of Fes el-Bali to this day. The Almohads rebuilt the Kasbah Bou Jeloud on the site of the former Almoravid kasbah.$^{:56}$ In Ya'qub al-Mansur's time the kasbah was endowed with a new congregational mosque, the Bou Jeloud Mosque, which still stands today (with later modifications). Nearby, the Almohads also built the first kasbah occupying the site of what is now the Kasbah an-Nouar.$^{:109}$ Muhammad al-Nasir reconstructed and expanded the Al-Andalusiyyin Mosque between 1203 and 1207.$^{:10–11}$
It is in this period that the city begins to be referred to as a major city and acquires a high reputation among contemporary writers like al-Idrisi and al-Marrakushi. Under Almohad rule the city grew to become one of the largest in the world between 1170 and 1180, with an estimated 200,000 people living there. Not all the land within the city walls was densely inhabited; much of it was still relatively open and was occupied by crops and gardens used by the inhabitants. The city's economy was prosperous and multiple industries, such as the tanneries, thrived.$^{:56–59}$ Each industry was generally concentrated in a particular neighbourhood or neighbourhoods; an arrangement which remained for most of the city's history. Most industries were established near the center but some, like the potters, were established in the outer districts because they needed more room.$^{:56–59}$ The Sebou River (into which the Fez River flows) was used to bring goods to the city; boats navigated the river from the Atlantic coast up to a point near the city, before unloading and finishing the journey overland.$^{:192}$ Fez, along with other major cities in the region, also played a role in trans-Saharan trade. Multiple trade routes existed, but caravans that took the route through Sijilmasa would usually continue from there to either Fez or Tlemcen. From Fez, goods could then travel further north to the Strait of Gibraltar and to Al-Andalus.$^{:201}$ By the end of the Almohad era, Fez had thus become not only a center of local and regional trade but also a center of consumption and an exporter of its own products.$^{:202}$

## Golden age under the Marinids (13th-15th centuries)

Fez regained its political status and became the capital of Morocco during the Marinid dynasty, a Zenata Berber dynasty, between the 13th and 15th century. The Marinid leader Abu Yahya besieged and captured Fez in 1248, along with other cities, after defeating an Almohad army in eastern Morocco. The traditional urban population of the city was resistant to the rule of the nomadic Marinids, however, and rebelled again in 1250, although it failed to throw off Marinid control.$^{:104}$$^{:156}$ The Marinids initially struggled against Yagmurasan, the Zayyanid ruler of Tlemcen, for control of Sijilmasa, but after 1272 they took the city definitively, allowing them to retain control of the trans-Saharan trade routes that passed there and continuing to divert them towards Fez.
The Marinids initially established themselves in the old Almohad kasbahs of Fez (the Kasbah Bou Jeloud and the Kasbah an-Nouar) as well as on the hill overlooking the north side of the city. This hill, where the ruins of the Marinid Tombs still stand, was occupied by a large palace and fortification where the Marinid ruler resided, though little of this remains today. In 1276 Abu Yusuf Ya'qub built an entirely new administrative city or royal citadel to the west of the old city, on higher ground overlooking it. In addition to putting more distance between the sultan and the restive population, another reason for building the new city was that the Almohad kasbahs, which were strictly military compounds, lacked the space required to establish a royal court and to house the Marinid troops. Moreover, by this time Abu Yusuf Ya'qub had also conquered Marrakesh (1269) and defeated the last Almohad holdouts in Tinmal (1275). Building a new palace-city was a frequent preoccupation of North African and Andalusi dynasties wishing to demonstrate their power, and so the foundation of the new city also symbolized the new era of Marinid rule.$^{:61–63}$$^{:105–106}$
The new city was named al-Madinat al-Bayda (Arabic: المدينة البيضاء, lit. 'the White City'), but it soon became known as Fes el-Jdid (Arabic: فاس الجديد, romanized: Fās al-Jadīd, lit. 'New Fez'), while the old city became known as Fes el-Bali (Arabic: فاس البالي, lit. 'Old Fez').$^{:61}$ The new city included the royal palace of the sultans (the Dar al-Makhzen), the administrative offices of the state, and the headquarters of the army.$^{:62}$ The city had its own main mosque, the Great Mosque, and its own set of fortified walls and gates. Most of its outer perimeter was protected by a set of double walls; a tall inner wall with heavy square towers at regular intervals and a smaller outer wall with minor towers. Its northern entrance, at the beginning of the road to Meknes, consisted of a fortified bridge (now the Old Mechouar) over the Oued Fes, between two gates, Bab es-Sebaa (Arabic: باب السبع, lit. 'Gate of the Lion') and Bab al-Qantara (Arabic: باب القنطرة, lit. 'Gate of the Bridge'). Inside, the city was further subdivided into different districts, some of which, including the Dar al-Makhzen, had walls and gates separating them from the others. Another district, initially known as Hims and later converted into the Jewish Mellah, was also added to the south.$^{:62–66}$ In 1287 Sultan Abu Ya'qub Yusuf (son of Abu Yusuf Ya'qub) created a vast pleasure garden, known as Al-Mosara, to the north, just outside the city but encompassed by its own protective wall. The gardens were watered via an aqueduct which drew water from the Oued Fes through an enormous noria (type of water wheel), approximately 26 meters in diameter, which was located on the west side of Bab es-Sebaa. Although the gardens and the water wheel have since disappeared, traces of the former aqueduct are visible in the western wall of the New Mechouar today and also in the large octagonal towers of Bab Segma, one of the former gates to the garden.
Fez reached its golden age in the Marinid period. It is from this period that the city's reputation as an important intellectual centre largely dates. The Marinid rulers established the first formal madrasas in Morocco here in the city. The madrasas became a hallmark of Marinid architecture, with its striking blending of Andalusian and Almohad traditions. Between 1271 and 1357 at least seven madrasas were built in Fez, which are considered among the best examples of Moroccan architecture and some of the most richly decorated monuments in Fez. The first of these was the Saffarin Madrasa in 1271, followed by the Sahrij Madrasa in 1321, the al-Attarine and Sba'iyin madrasas in 1323, and the Mesbahiya Madrasa in 1346. All of these madrasas were built near the Qarawiyyin or Andalusiyyin mosques and were designed to complement those older institutions, in particular by providing housing for students from outside the city. Another madrasa was also built near the Great Mosque of Fes el-Jdid in 1320, though this center never succeeded in rivaling the older educational centers in Fes el-Bali.$^{:114}$ The only truly independent madrasa (for a time) was the large Bou Inania Madrasa, commissioned by Sultan Abu Inan and completed in 1355, which also served as its own Friday mosque and was located in the western part of Fes el-Bali.
Meanwhile, many scholars consider that the high point of the Qarawiyyin as an intellectual and scholarly center was in the 13th-14th centuries, when the curriculum was at its broadest and its prestige had reached new heights after centuries of expansion and elite patronage.$^{:141}$ Among the subjects taught around this period or shortly after were traditional religious subjects such as the Qur'an and Fiqh (Islamic jurisprudence) as well as other sciences like grammar, rhetoric, logic, medicine, mathematics, astronomy and geography.$^{:455}$
Ibn Khaldun, the famous historian and philosopher, spent time in Fez after 1354. He started as the secretary of Sultan Abu Inan but subsequently became involved in the intrigues of Marinid dynastic politics, spending time in jail at the end of Abu Inan's reign. Ibn Battuta also passed through the city on his way to Sijilmasa in the 14th century and described it in his writings. Ibn al-Khatib, the Andalusi poet and writer, also spent time here following his Nasrid master Muhammad V into exile for a few years between 1358 and 1362. After becoming embroiled in political intrigues in Granada he fled to North Africa again and was accused of heresy, eventually being put on trial in Fez and killed while in prison in 1375; his body was reportedly burnt in front of Bab Mahrouk and was buried in the nearby cemetery.
The Jewish quarter of Fez, the Mellah (Arabic: ملاح), was created in Fes el-Jdid at some point during the Marinid period. The exact date and circumstances of its formation are not firmly established, but many scholars date the transfer of the Jewish population from Fes el-Bali to the new Mellah to the 15th century, a period of political tension and instability. In particular, Jewish sources describe the transfer as a consequence of the "rediscovery" of Idris II's body in the heart of the city in 1437, which caused the surrounding area – or possibly the entire city – to acquire a "holy" (haram) status, requiring that non-Muslims be removed from the area. In 1438, under pressure from the shurafāʾ, Sultan Abū Muḥammad ʿAbd al-Ḥaqq made Jewish merchants with businesses in the qaysāriyya (the main market of Fes el Bali, near the site of the discovery) abandon them and move to the Mellah. Many Fessi Jews chose to become Muslims and keep their homes and livelihoods in Old Fes. They formed a group called the bildiyyīn. Numerous Fessi Jews converted to Islam throughout the premodern period, but the conversions spiked in the mid-fifteenth century. Powerful families, such as the Bannānī, Ibn Shaqrūn, Bannīs, Barrāda, and Gassūs families, adopted Islam.
The Jewish community had initially consisted of indigenous local Jews but these were joined by Sephardic Jews from the Iberian Peninsula (known as the Megorashim) in subsequent generations, especially after the 1492 expulsion of Jews from Spain. The ensuing waves of Spanish/Andalusi Jews migrating to Fez and North Africa increased the Jewish population in the city and also altered the community's social, ethnic, and linguistic makeup. The influx of migrants also revitalized Jewish cultural activity in the following years, while splitting the community along ethnic lines for many generations. In 1526, Fez hosted various Sephardic communities, with three originating from Castile and one from Seville, the latter maintaining a separate identity. The Megorashim of Spanish origin retained their heritage and their Spanish language while the indigenous Moroccan Toshavim, who spoke Arabic and were of Arab and Berber heritage, followed their own traditions. Members of the two communities worshiped in separate synagogues and were even buried separately. It was only in the 18th century that the two communities eventually blended together, with Arabic eventually becoming the main language of the entire community while the Spanish (Sephardic) minhag became dominant in religious practice.
The 1465 Moroccan revolt overthrew the last Marinid sultan. In 1472 the Wattasids, another Zenata dynasty which had previously served as viziers under the Marinid sultans, succeeded as rulers of Morocco from Fez.$^{:114–115}$ They perpetuated the structure of the Marinid state and continued its policies, but were unable to control all of Morocco.$^{:15}$$^{:207–209}$ They did not contribute significantly to the physical fabric of Fez.

## Decline under the Saadians (16th and early 17th centuries)

In the 16th century the Saadians (or Saadis) rose to power in southern Morocco and challenged the Wattasids. In the meanwhile, the Ottoman Empire came close to Fez after the conquest of Algeria in the 16th century. In January 1549 the Saadian sultan Mohammed ash-Sheikh took Fez and ousted the last Wattasid sultan Ali Abu Hassun. They later retook the city in 1554 with Ottoman support, but this reconquest was short-lived and later that same year the Wattasids were decisively defeated in the Battle of Tadla by the Saadians. The Ottomans would try to invade Morocco after the assassination of Mohammed ash-Sheikh in 1558, but were stopped by his son Abdallah al-Ghalib at the battle of Wadi al-Laban north of Fez. Hence, Morocco remained the only North-African state to remain outside Ottoman control.
After the death of Abdallah al-Ghalib a new power struggle would emerge. Abd al-Malik, Abdallah's brother, enlisted Ottoman support and ousted his nephew Abu Abdullah from power in 1576. The latter would flee to Portugal where he asked king Sebastian of Portugal for help to regain his throne. This would lead to the Battle of Wadi al-Makhazin (also known as the Battle of Alcácer Quibir or the Battle of the Three Kings) where Abd al-Malik's army would defeat the invading Portuguese army with the support of his Ottoman allies, ensuring Moroccan independence. Abd al-Malik himself also died during the battle and was succeeded by Ahmad al-Mansur.
The Saadians, who used Marrakesh again as their capital, did not lavish much attention on Fez, with the exception of the ornate ablutions pavilions added to the Qarawiyyin Mosque's courtyard during their time. It was likely during the Saadian period that the former royal gardens of the Marinids, the Mosara, fell into disuse and began to fade. Perhaps as a result of persistent tensions with the city's inhabitants, the Saadians built a number of new forts and bastions around the city which appear to have been aimed at keeping control over the local population. They were mostly located on higher ground overlooking Fes el-Bali, from which they would have been easily able to bombard the city with canons. These include the Kasbah Tamdert, just inside the city walls near Bab Ftouh, and the forts of Borj Nord (Borj al-Shamali) on the hills to the north, Borj Sud (Borj al-Janoub) on the hills to the south, and the Borj Sheikh Ahmed to the west, at a point in Fes el-Jdid's walls that was closest to Fes el-Bali. These were built in the late 16th century, mostly by Sultan Ahmad al-Mansur. Two other bastions, Borj Twil and Borj Sidi Bou Nafa', were also built along Fes el-Jdid's walls south of Borj Sheikh Ahmed. The Borj Nord, Borj Sud, and these bastions (sometimes referred to as the bastioun in Arabic) of Fes el-Jdid are the only fortifications in Fez to demonstrate clear European (most likely Portuguese) influence in their design, updated to serve as defenses in the age of gunpowder. Some of them may have been built with the help of Christian European prisoners of war from the Saadians' victory over Portuguese in 1578.
After the long and impressive reign of Ahmad al-Mansur, the Saadian state fell into civil war between his sons and potential successors. Fez became a rival seat of power for a number of brothers vying against other family members ruling from Marrakesh and both cities changed hands multiple times until the internecine conflict finally ended in 1627. During this time, the inhabitants of the city had violent confrontations with the Chraga, an Arab tribe which the Saadians had installed in the surrounding countryside as a garrison force (known as a guich or "army" tribe). In 1611 the population of the city revolted and even massacred many of the Chraga in apparent retaliation against crimes committed by some of their members.$^{:81–82}$ Despite the reunification of the realm after 1627, the Saadians were in full decline and Fez had already suffered considerably from the repeated conquests and reconquests during the conflict. As the Saadian sultanate collapsed, both the city and the wider country descended into relative anarchy. The two shores of the city, the 'Adwat al-Qarawiyyin and 'Adwat al-Andalusiyyin (the latter now also known simply as al-'Adwat), fell into rivalries reminiscent of the city's early history, while new rivalries developed between different clans within the western (Qarawiyyin) shore. Fes el-Jdid, which was the center of the official government, also struggled against Fes el-Bali, the old city.$^{:82}$
In 1641, Muhammad al-Haj of the Sanhaja Amazigh Dilā' Sufi order of the Middle Atlas occupied Fes.$^{:88}$ This time was particularly difficult for Fessi Jews. A Jewish chronicle of the time recounts that in 1646 synagogues were ordered to close and were subsequently desecrated, damaged, or destroyed.$^{:88–89}$ The city was not receptive to the Dilā' either, and for a brief period in 1651 they rebelled and invited Muhammad ibn Muhammad al-Sharif, one of the early Alaouite sultans, to take control of the city.$^{:82–83}$$^{:229}$

## Early Alaouite period (17th and 18th centuries)

It was only when the true founder of the future Alaouite state, Moulay Rashid, took Fez in 1666 that the city saw a revival and became the capital again, albeit briefly. Moulay Rashid set about restoring the city after a long period of neglect. He built the Kasbah Cherarda (also known as the Kasbah al-Khemis) to the north of Fes el-Jdid and of the Royal Palace in order to house a large part of his tribal troops. He also restored or rebuilt what became known as the Kasbah an-Nouar, which became the living quarters of his followers from the Tafilalt region (the Alaouite dynasty's ancestral home). For this reason, the kasbah was also known as the Kasbah Filala ("Kasbah of the people from Tafilalt"). Moulay Rashid also built a large new madrasa, the Cherratine Madrasa, in 1670. Upon his death in 1672 he was buried in the Mausoleum of Sidi Harazem, in the southern cemetery of the city outside Bab Ftouh.
After his death Fez underwent another dark period. Moulay Isma'il, his successor, apparently disliked the city – possibly due to a rebellion there in his early reign – and chose nearby Meknès as his capital instead. He also frequently imposed heavy taxes on the city's inhabitants and sometimes even forcibly transferred parts of its population to repopulate other cities in the country. Nonetheless, he did restore or rebuild some major monuments in the city, such as the Zawiya of Moulay Idris II.
After Isma'il's death things only worsened as Morocco plunged into anarchy and decades of conflict between his sons who vied to succeed him. Fez suffered particularly from repeated conflicts with the Udayas (or Oudayas), a guich tribe (vassal tribe serving as a garrison and military force) previously installed in the Kasbah Cherarda by Moulay Isma'il. Sultan Moulay Abdallah, who reigned intermittently during this period and used Fez as a capital, was initially welcomed in 1728–29 as an enemy of the Udayas, but relations between him and the city's population quickly soured due to his choice of governor. He immediately built a separate fortified palace in the countryside, Dar Dbibegh, where he resided instead. For nearly three more decades the city remained in more or less perpetual conflict with both the Udayas and the Alaouite sultans.
Starting with the reign of Moulay Muhammad ibn Abdallah, between 1757 and 1790, the country stabilized and Fez finally regained its fortunes. Although its status was partly shared with Marrakesh, it remained the capital of Morocco for the rest of the Alaouite period up to the 20th century. The Udayas, who had been a burden on the population of Fez, became the main challenge to the new sultan's power, and in 1760 Muhammad ibn Abdallah was forced to march with an army to Fez where he arrested their leaders and destroyed their contingents, killing many of their soldiers. In the aftermath the sultan created a new, much smaller, Udaya regiment which was given new commanders and garrisoned in Meknes instead.$^{:240}$
There was a brief period of disorder under Moulay Yazid (ruled 1790–1792) and Moulay Slimane (ruled 1792–1822), with the sultans in Fez losing control of most of the rest of Morocco between 1790 and 1795.$^{:241–242}$ The reign of Moulay Yazid was especially disastrous for the city. The Udayas tribe was brought back as a local garrison. During these two years the sultan forced the entire Jewish community to move to an open area next to the Kasbah Cherarda, north of Fes el-Jdid. The Mellah was occupied by tribal troops allied to the sultan, its main synagogue was replaced by a mosque, and the district itself was permanently reduced in size. It was only after Moulay Yazid's death that the chief Muslim qadi (judge) of Fez ordered the Mellah to be restored to the Jewish community, along with the demolition of the mosque built by Yazid's troops.
Otherwise, however, the city benefitted from a long era of relative peace. It remained a major economic center of the region even during troubled times. The Alaouites continued to rebuild or restore various monuments, as well as to expand the grounds of the Royal Palace a number of times. The sultans and their entourage also became more and more closely associated with the elites of Fez and other urban centers, with the ulama (religious scholars) of Fez being particularly influential. After Moulay Slimane's death powerful Fassi families became the main players of the country's political and intellectual scene.$^{:242–247}$ After another episode of troubles in 1820, his successor Abd al-Rahman expelled the Udayas from Fez permanently in 1824.$^{:89}$

## Prosperity and growth in the 19th and early 20th centuries

The Tijani Sufi order, started by Ahmad al-Tijani (d. 1815), had its spiritual center in Fez after al-Tijani moved here from Algeria in 1789.$^{:244}$ The order spread quickly among the literary elite of North West Africa and its ulama had significant religious, intellectual, and political influence in Fez and beyond. Until the 19th century the city was also the only manufacturing center of fezzes (also known as the tarboosh). The fortunes of the Jewish community also improved considerably in the 19th century when the expansion of contact and trade with Europe allowed the Jewish merchant class to place themselves at the center of international trade networks in Morocco. This also led to a greater social openness and a shift in tastes and attitudes, especially among richer Jews, who built luxurious residences in the upper Mellah. Likewise, rich Muslim families and elites built their own grand mansions, especially in the garden districts of al-'Uyun in the southwestern part of Fes el-Bali. Examples from the late 19th century and early 20th century include the Dar Moqri, Dar Glaoui, Dar Mnebhi and Dar Jama'i.$^{:222}$
In 1873, in response to the attempt of Sultan Hassan I to introduce a market tax called the mukūs (المكوس), the guilds of the tanneries of Fes led a revolt that turned violent.
The last major change to Fez's topography before the 20th century was made during the reign of Sultan Hasan I, who finally connected Fes el-Jdid and Fes el-Bali by building a walled corridor between them. Within this new corridor, between the two cities, were built new gardens and summer palaces used by the royals and the capital's high society, such as the Jnan Sbil Gardens and the Dar Batha palace. Moulay Hassan also expanded the old Royal Palace itself, extending its entrance up to the current location of the Old Mechouar while adding the New Mechouar, along with the Dar al-Makina, to the north. This had the consequence of also splitting the Moulay Abdallah neighbourhood to the northwest from the rest of Fes el-Jdid.
With the Conditioned Bay'ah, Fes played a central role in the Hafidiya, the brief civil war that erupted when Sultan Abd al-Hafid challenged his heavily Europe-allied brother Abdelaziz for the throne.$^{:76}$ The ulama of Fez, led by the Sufi modernist Muhammad Bin Abdul-Kabir Al-Kattani, offered their conditioned support to Abd al-Hafid, which turned the tide of the conflict. Abdelaziz was defeated in the Battle of Marrakesh in 1908.$^{:76–78}$Abdelhafid's reign soon deteriorated and in early 1911 the sultan was besieged in Fez by the tribes of the Middle Atlas. Abdelhafid appealed for French help and a French force under Colonel Charles Émile Moinier [fr] arrived in Fez on May 21 and established a command centre at Dar Dbibegh.$^{:313}$$^{:78}$
By 1912, on the eve of French colonial rule, the city had an estimated population between 80,000 and 100,000.$^{:152}$

## French colonial rule (1912–1956)

In 1912 the French Protectorate was instituted over Morocco following the Treaty of Fes. One immediate consequence was the 1912 riots in Fez, a popular uprising which included deadly attacks targeting Europeans as well as native Jewish inhabitants in the Mellah, followed by an even deadlier repression. Fez and its Dar al-Makhzen ceased to be the center of power in Morocco as the first French resident general, Hubert Lyautey, decided to move the administrative capital of the Protectorate to Rabat in 1912–1913, which has remained the capital ever since.$^{:149}$
A number of social and physical changes took place at this period and across the 20th century. Starting under Lyautey, one important policy with long-term consequences was the decision to largely forego redevelopment of existing historic walled cities in Morocco and to intentionally preserve them as sites of historic heritage, still known today as "medinas". Instead, the French administration built new modern cities (the Villes Nouvelles) just outside the old cities, where European settlers largely resided with modern Western-style amenities. This was part of a larger "policy of association" adopted by Lyautey which favoured various forms of indirect colonial rule by preserving local institutions and elites, in contrast with other French colonial policies that had favoured "assimilation". The existence today of a Ville Nouvelle ("New City") alongside a historic medina in Fez was thus a consequence of this early colonial decision-making. The Ville Nouvelle also became known as Dar Dbibegh by Moroccans, as the former palace of Moulay Abdallah was located in the same area. The French administration did still build some new structures in the old city, often emulating the local Moroccan style, such as the now iconic Bab Bou Jeloud gate in 1913.
The creation of the separate French Ville Nouvelle to the west had a wider impact on the entire city's development. While new colonial policies preserved historic monuments, it also had other consequences in the long-term by stalling urban development in these heritage areas. Scholar Janet Abu-Lughod has argued that these policies created in Morocco a kind of urban "apartheid" between the indigenous Moroccan urban areas – which were forced to remain stagnant in terms of urban development and architectural innovation – and the new planned cities which were mainly inhabited by Europeans and which expanded to occupy lands formerly used by Moroccans outside the city. This separation was partly softened, however, by wealthy Moroccans who started moving into the Ville Nouvelles during this period. By contrast, the old city (medina) of Fez was increasingly settled by poorer rural migrants from the countryside.$^{:26}$ Fez also played a role in the Moroccan nationalist movement and in protests against the French colonial regime. Many Moroccan nationalists received their education at the Al-Qarawiyyin University and some of their informal political networks were established thanks to this shared educational background.$^{:140,146}$ In July 1930, the Al-Qarawiyyin's students and other inhabitants participated in protests against the Berber Dahir decreed by the French authorities in May of that year.$^{:143–144}$ In 1937 the Al-Qarawiyyin mosque and R'cif Mosque were some of the rallying points for demonstrations in response to a violent crackdown on Moroccan protesters in the nearby city of Meknes, which ended with French troops being deployed across Fes el-Bali and at the mosques themselves.$^{:387–389}$$^{:168}$ Towards the end of World War II, Moroccan nationalists gathered in Fez to draft a demand for independence which they submitted to the Allies on January 11, 1944. This resulted in the arrest of nationalist leaders followed by the violent suppression of protests across many cities, including Fez.$^{:255}$

## After independence and up to present-day (after 1956)

After Morocco regained its independence in 1956 many of the trends begun under colonial rule continued and accelerated during the second half of the 20th century. Much of Fez's bourgeois classes moved to the growing metropolises of Casablanca and the capital, Rabat. The Jewish population was particularly depleted, either moving to Casablanca or emigrating to countries like France, Canada, and Israel. Although the population of the city grew, it did so only slowly up until the late 1960s, when the pace of growth finally accelerated.$^{:216}$ Throughout this period (and up to today) Fez nonetheless remained the country's third largest urban center.$^{:26}$$^{:216}$ Between 1971 and 2000, the population of the city roughly tripled from 325,000 to 940,000.$^{:376}$ The Ville Nouvelle became the locus of further development, with new peripheral neighbourhoods – with inconsistent housing quality – spreading outwards around it. In 1963 the University of Al-Qarawiyyin was reorganized as a state university, while a new public university, Sidi Mohamed Ben Abdellah University, was founded in 1975 in the Ville Nouvelle. In 1981, the old city, consisting of Fes el-Bali and Fes Jdid, was classified as a UNESCO World Heritage Site.
During this period, however, Moroccans were also subject to serious social inequalities and economic precarity, particularly under the repressive reign of King Hassan II and the period known as the Years of Lead (roughly 1975–1990).$^{:170}$ Fez was strongly affected by unemployment and lack of housing. Austerity measures led to several riots and uprisings across other cities during the 1980s. On December 14, 1990, a general strike was called by two major trade unions to demand an increase to minimum wage and other measures. In Fez this broke into protest and rioting led by university students and youths. The death of one of the students further inflamed protests, resulting in buildings being burned and looted, particularly symbols of wealth such as the Hôtel des Mérinides, a luxury hotel overlooking Fes el-Bali and dating to the time of Lyautey. While the official death toll was 5 people, the New York Times reported a toll of 33 people and quoted an anonymous source claiming the real death toll was likely higher. The government denied reports that the deaths were due to the intervention of security forces and armored vehicles. Many of those arrested were later released and the government promised to investigate and raise wages, though some of these measures were dismissed by the opposition.$^{:377}$
Today Fez remains a regional capital and one of Morocco's most important cities. Many of the former notable families of Fez still make up a large part of the country's political elite. It is also a major tourism destination due to its historical heritage. In recent years efforts have been underway to restore and rehabilitate the old medina, ranging from the restoration of individual monuments to attempts to rehabilitate the Fez River.