Three sedimentary subenvironments, palustrine (GP), marginal lacustrine (GML) and central lacustrine (GCL), were compared regarding water chemistry and microbial activity in order to explain the differences in the carbonate mineralogical composition of the upper sediment layer in Gallocanta Lake, a shallow hypersaline environment in Northeastern Spain. Horizontal heterogeneity was considerable, salinity ranged from 5 to 116 (parts per thousand) for the GP and GCL subenvironments respectively. Sulfate, Mg2+, and Ca2+ concentrations covaried among them and with salinity. The relative abundance of Mg-bearing carbonates, including high-Mg calcite, dolomite and hydrated Ca-magnesite, increased with the salinity. They were absent from the GP subenvironment, where only calcite precipitates, and maximum abundances were found in the GCL subenvironment (61%), where salinity, sulfate, and Mg2+ concentrations were highest. Every subenvironment presented specific microecological characteristics. The microbial community of the GCL subenvironment lacked of oxygenic photosynthesis, while the microbial communities of GML and GP subenvironments were photo-synthetically active. Vertical profiles of sulfide and pH at the water-sediment interface revealed clear differences between the GCL and GML subenvironments as well. Sulfide was detected below the oxic layer in the GCL subenvironment and increased with depth, but it was undetected in the GML subenvironment. The precipitation of Mg-bearing carbonates with different Mg:Ca proportions occurs at different stage along a biogeochemical gradient, where increasing salinity and sulfate content favour the anaerobic oxidation of organic carbon by dissimilatory sulfate reduction.