One of the chief challenges facing both small-scale and large-scale settlements in any region is water management, and in the case of the Maghrib, migratory populations and the extreme contrast between desert, mountain, and Mediterranean climates have resulted in various solutions to collect water resources. The negotiation of these resources was not only a matter of imperial civic projects, but also of political and territorial network control, and the various dynasties that have reigned in the Maghrib since the Islamic conquest have had to contend with these issues.
Unlike regions such as Greater Syria and al-Andalus, the Maghrib had little ancient hydraulic infrastructure upon which to build, since few Roman or Carthaginian settlements penetrated the interior further than Volubilis. Much of the pre-Islamic era engineering was therefore characterized by smaller, localized methods of collecting water—canals connected to nearby wadis, for example—but the need to centralize water collection was somewhat undermined by a semi-nomadic population that had to coordinate its movements with the seasonal availability of water. The new Islamic cities such as Qayrawān, Fez, and Marrakesh thus had to develop large-scale methods of water management pretty much from scratch.
Some of the earliest examples, such as the Aghlabid Basins outside Qayrawān, were constructed to supply the frontier cities of the Islamic conquest with adequate water resources; and it was this need that marked the beginning of imperial involvement in water management. Methods adapted from the Levant, Egypt, Mesopotamia, and the Iranian Plateau made their way to North Africa with the incoming wave of Arab officials and administrators. Grand reservoirs exemplified by Aghlabid Basins, known in Arabic as mājil (pl. mawājil), were developed both in order to trap running water before it disappeared underground, and to tap the subterranean water tables. The Fatimids would later add to these reservoirs an aqueduct to bring water from nearby springs, but long-distance water transportation remained a difficult endeavor due to the fractured and shifting political alliances of the region.
It was not until the reigns of the Almoravids and the Almohads in the eleventh and twelfth centuries that water resources, particularly in urban areas, were developed and managed over great distances. Both dynasties, who ruled from Marrakesh, spent considerable resources to supply the city with water for drinking, display, and irrigation. The Almoravids focused on developing a system of khettaras, subterranean canals that used gravity to direct water from an uphill aquifer to irrigate fields or reservoirs many kilometers away. From above, khettaras appeared as a series of wells that tapped into the water table, allowing access into and out of the aquifer itself. Under the Almohads, khettaras were supplemented by canals that diverted seasonal wadis from the Atlas foothills some 40 km away into the suburban region of Marrakesh (see Agdal Garden), revealing an impressive amount of regional control as evidenced by the sheer scope of such a project.
Though all of these methods relied on gravity, it became necessary, as North African cities expanded, to move water to higher locations, prompting the use of water wheels as early as the middle of the thirteenth century in cities like Fez. Though these wheels are no longer extant, their large size and royal commission from Andalusi hydraulic engineers is attested by such sources as historian Ibn al-Khātib’s al-Iḥāṭa fī taʾīkh Gharnāṭa.