[1] Finally, a more subtle or symbolic function of the city walls was to formally define the borders of the urban space, within which certain rules, principles, or regulations might apply.
[1] With the advent of gunpowder, the medieval walls became partly redundant as military defenses against other armies; however they remained essentially unchanged in the following centuries and were not rebuilt or redesigned to protect against artillery.
Only on one occasion was Fes taken by a foreign army: the Ottomans, with the help of a Wattasid dynasty survivor, occupied it in 1554 for less than a year before the Moroccan Saadis took it back.
[3] By contrast, local Bedouin or other potential raiders from the countryside were rarely equipped with artillery, so the existing walls were sufficient to defend against them.
The walls of Fès, like those of Marrakesh and most historic cities in Morocco, were generally built in rammed earth, an ancient building technique found across the Near East, Africa, and beyond.
[9] In many cases walls were covered with a coating of lime, stucco, or other material to give them a smooth surface and to better protect the main structure.
[7] This type of construction required consistent maintenance and upkeep, as the materials are relatively permeable and are more easily eroded by rain over time; in parts of Morocco, (especially near the Sahara) kasbahs and other structures made with a less durable composition (typically lacking lime) can begin to crumble apart in less than a couple of decades after they've been abandoned.
[7][10] As such, old structures of this type remain intact only insofar as they are continuously restored; some stretches of wall today appear brand new due to regular maintenance, while others are crumbling.
[3][1][11] However, due to Fes's continuing economic and military importance, the Almohad caliph Ya'qub al-Mansur ordered the reconstruction of the ramparts.
[12]: 36 [11]: 606 The walls were completed by his successor Muhammad al-Nasir in 1204,[12] giving them their definitive shape and establishing the perimeter of Fes el-Bali to this day.
[3][11][1] (Although according to another author, the reconstruction of the walls was ordered by Muhammad al-Nasir in 1212, following his defeat at Las Navas de Tolosa in Spain.
[3] Another district, initially known as Hims and later converted into the Jewish Mellah, was also added to the south of Bab Semmarine, between the city's inner and outer walls on this side.
[14] Today, an original section of these walls has been well-preserved between the Lalla Mina and Agdal Gardens, inside the perimeter of the Dar al-Makhzen.
[1][3] The extra fortification on this side has been interpreted has an indication that the royal city's defenses were as much about protecting the regime from the restive inhabitants of old Fes as they were aimed at warding off external invaders.
[1] Nonetheless, the Marinids did also restore and repair the walls of Fes el-Bali, in addition to devoting their attention to the construction of prestigious madrasas and other embellishments in the old city.
Today, Fes el-Jdid's walls and gates still date to a large extent from the Marinid period, generally from Abu Yusuf Ya'qub's initial construction.
[3] Upon retaking the city, the Saadi authorities took revenge upon some of the local leaders and treated the general population poorly, further enshrining the inhabitants' hostility to the new dynasty.
[3] Presumably as a result of this persisting tension, the Saadis built a number of new forts and bastions around the city which appear to be aimed at keeping control over the local population.
The term "kasbah" (Arabic: قَـصَـبَـة, romanized: qaṣabah) was used to denote a large number of fortified enclosures ranging from small garrison forts to larger citadels, many of them named after the ethnic or geographic origin of the soldiers posted there.
[16] The term borj (Arabic: برج), generally meaning "tower", was applied to a number of heavily fortified military structures and bastions, especially those of the Saadi era.