In the Mader Basin of the eastern Anti-Atlas, Middle Devonian carbonate mounds were established on a gently sloping ramp at moderate water depths. Primary stromatactis cavities in these mounds exhibit early marine, shallow burial, and deeper burial cementation. The mound matrix was affected by neomorphic alteration, stylolitization, and dolomitization. Earliest cementation occurred in the marine environment. Nonluminescent to blotchy-luminescent, cloudy radiaxial calcites of originally high Mg-calcite composition coat the walls of stromatactis cavities and take up more than 50% of the primary pore space. The isotopic signature (delta 18 O = -2.6 (+ or - 0.2) per thousand PDB; delta 13 C = +2.7 (+ or - 0.5) per thousand PDB) is close to that of nonluminescent, fabric-retentive brachiopod shells in the same mounds, and taken as the nearly pristine stable isotopic signature of Mader Basin seawater. The high delta 18 O values, compared with Middle Devonian data of North America, are interpreted to result from the mid-latitudinal (ca. 35 degrees S), temperate-water settings of the Mader Basin carbonate mounds. The transition to the shallow burial realm is indicated by a typical non-bright-dull luminescence sequence. Nonluminescent scalenohedral cements pass into bright-luminescent and banded-luminescent scalenohedral cements, which are overgrown in turn by dull- to moderate-luminescent blocky spar. Meteoric influence on that cement sequence can be excluded. Deeper burial diagenesis is represented by stylolitization, ferroan calcite cementation, and neomorphic alteration of the fine-grained mound carbonates. Pressure solution and/or outgassing of CO 2 are possible ion sources for ferroan calcite precipitation in the remaining pore space. 18 O depletion delta 18 O = -6.8 to -8.9 per thousand PDB) of these cements can be calculated to elevated precipitation temperatures of 21-33.5 degrees C and burial depths of 420-670 m. Microspar, making up the bulk of the mounds, was formed by a one-step transformation of a precursor calcitic micrite. Low delta 18 O values (-6.9 (+ or - 2.1) per thousand PDB), mottled luminescence, and high Fe concentrations indicate that this transformation also took place in the deeper burial realm.