The architecture of Fez, Morocco, reflects the wider trends of Moroccan architecture dating from the city's foundation in the late 8th century and up to modern times. The old city (medina) of Fes, consisting of Fes el-Bali and Fes el-Jdid, is notable for being an exceptionally well-preserved medieval North African city and is classified as a UNESCO World Heritage Site. A large number of historic monuments from different periods still exist in it today, including mosques, madrasas, synagogues, hammams (bathhouses), souqs (markets), funduqs (caravanserais), defensive walls, city gates, historic houses, and palaces.

History

Early history (9th-10th centuries)

The city was founded on a bank of the Oued Fes (Fez River) by Idris I in 789, founder of the Idrisid dynasty. His son, Idris II (808),"Fes". Encyclopædia Britannica. 2007. Britannica Concise Encyclopedia. 3 Mar. 2007 built a settlement on the opposing river bank in 809 and moved his capital here from Walili (Volubilis). These settlements would soon develop into two walled and largely autonomous sites, often in conflict with one another: Madinat Fas and Al-'Aliya. The early population was composed mostly of Berbers, along with hundreds of Arab warriors from Kairouan who made up Idris II's entourage. 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.Arab emigration to Fez increased afterwards, including Andalusi families of mixed Arab and Iberian descent p. 55 who were expelled from Córdoba in 817–818 after a rebellion against the Al-Hakam I, as well as Arab families banned from Kairouan (modern Tunisia) after another rebellion in 824. These immigrants gave the city its Arabic character. The Andalusians settled mostly in Madinat Fas, while the Tunisians found their home in Al-'Aliya. These two waves of immigrants would subsequently give their name to the sites 'Adwat Al-Andalus and 'Adwat al-Qarawiyyin. Both the Qarawiyyin Mosque and the Andalusiyyin Mosque are believed to have been founded around this period, in 859. The decline of the Idrisid dynasty afterward resulted in Fez changing hands between various empires and local factions in the 10th century.

The earliest surviving Islamic-era monuments in Fez, the al-Qarawiyyin and Andalusi mosques, were built in the hypostyle form and made early use of the horseshoe arch. These reflected influences from major early monuments like the Great Mosque of Kairouan and the Great Mosque of Córdoba. In the 10th century much of northern Morocco, including Fez, came directly within the sphere of influence of the Umayyad Caliphate of Córdoba, with competition from the Fatimid Caliphate further east. Early contributions to Moroccan architecture from this period include expansions to the Qarawiyyin and Andalusi mosques and the addition of their square-shafted minarets, anticipating the later standard form of Moroccan minarets.

Almoravid and Almohad era (11th-13th centuries)

The rise of the Almoravids in the 11th century brought about the foundation of a new capital at Marrakesh to the south, and the Almohads after them also kept Marrakesh as their center of power. Nonetheless, Fes remained the second city of their empires. The city's merchant economic activity and its intellectual influence continued to grow. The Almoravids unified the two cities of Madinat Fas and Al-Aliya for the first time into one large city with a single set of walls. They also expanded the Al-Qarawiyyin Mosque, which functioned as a religious centre and also educational institution. When the Almohad leader Abd al-Mu'min besieged and conquered the city in 1145, he demolished the city's fortifications as punishment for its resistance. However, due to Fes's continuing economic and military importance, the Almohad caliph Ya'qub al-Mansur ordered the reconstruction of the ramparts. 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 Almoravid-Almohad period is considered one of the most formative stages of Moroccan and Moorish architecture, establishing many of the forms and motifs that were refined in subsequent centuries. The Almoravids adopted the architectural developments of al-Andalus, such as the complex interlacing arches of the Great Mosque in Cordoba and of the Aljaferia palace in Zaragoza, while also introducing new ornamental techniques from the east such as muqarnas ("stalactite" or "honeycomb" carvings). Outside of Fes, the Almohad Kutubiyya and Tinmal mosques are often considered the prototypes of later Moroccan mosques. Likewise, the monumental minarets (e.g. the Kutubiyya minaret, the Giralda of Seville, and the Hassan Tower of Rabat) and ornamental gateways (e.g. Bab Agnaou in Marrakesh, and Bab Oudaia and Bab er-Rouah in Rabat) of the Almohad period also established the overall decorative schemes that became recurrent in these architectural elements thenceforth. The minaret of the Kasbah Mosque of Marrakech was particularly influential and set a style that was repeated, with minor elaborations, in the following Marinid period.

Marinid period and golden age (13th-15th centuries)

Fez regained its political status and became recognised as the capital during the Marinid dynasty between the 13th and 15th centuries. In 1276 the Marinid sultan 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. This became known as Fes el-Jdid ("New Fes"), and included the royal palace of the sultans (Dar al-Makhzen), the administrative offices of the state, and the headquarters of the army. Fes el-Jdid had 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. 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. 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 (a type of water wheel), approximately 26 meters in diameter, which was located on the west side of Bab Dekkakin. 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.

The Marinids were also important in further refining the artistic legacy established by their predecessors. They built monuments with increasingly intricate and extensive decoration, particularly in wood and stucco. They were also the first to deploy extensive use of zellij (mosaic tilework in complex geometric patterns). Notably, they were the first to build madrasas, a type of institution which originated in Iran and had spread west. The madrasas of Fes, such as the Bou Inania, al-Attarine, and as-Sahrij madrasas, are considered among the greatest architectural works of this period.Kubisch, Natascha (2011). "Maghreb - Architecture" in Hattstein, Markus and Delius, Peter (eds.) Islam: Art and Architecture. h.f.ullmann. While mosque architecture largely followed the Almohad model, one noted change was the progressive increase in the size of the sahn or courtyard, which was previously a minor element of the floor plan but which eventually, in the subsequent Saadian period, became as large as the main prayer hall, and sometimes larger.

The architectural style under the Marinids was also very closely related to that found in the Emirate of Granada, in Spain, under the contemporary Nasrid dynasty. The decoration of the famous Alhambra is thus reminiscent of what was built in Fes at the same time. When Granada was conquered in 1492 by Catholic Spain and the last Muslim realm of al-Andalus came to an end, many of the remaining Spanish Muslims (and Jews) fled to Morocco and North Africa, resulting in another increase of Andalusian influence in Fez during subsequent generations.

Decline and development under the Saadians and Alawis (16th-19th centuries)

After the decline of the Marinid dynasty, Fes went into a mixed era of decline and occasional prosperity under the Saadians and Alawis. The Saadians, who used Marrakesh again as their capital, did not lavish much attention on Fes, with the exception of the ornate ablutions pavilions added to the Qarawiyyin Mosque's courtyard during their time. 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 Fes 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 at the Battle of the Three Kings in 1578.

The founder of the Alawi dynasty, Moulay Rashid, took Fes in 1666 and made it his capital. He 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 Alawi dynasty's ancestral home). For this reason, the kasbah was also known as the Kasbah Filala ("Kasbah of the people from Tafilalt"). After Moulay Rashid's death Fes underwent another dark period. His successor, Moulay Isma'il, moved the capital to Meknes, though he did sponsor some major construction projects in Fez. Notably, he completely rebuilt the Zawiya of Moulay Idris II between 1717 and 1720, giving the building most of its present form.