Trace element contents and distributions in authigenic quartz cement in deeply buried (2500–4000 m) Haushi Group sandstones from wells in Oman have been investigated in order to determine the factors that control trace element uptake during precipitation. Scanning electron microscope-cathodoluminescence images show well developed growth zones within the quartz cement, which correlate with chemical zonations observed in electron microprobe Al distribution maps. The most abundant trace elements are Al (50–3000 μg g −1), Li (1–100 μg g −1), Na (1–40 μg g −1), and Ge (0.3–5 μg g −1) with a strong linear correlation between Li and Al and a weaker one between Ge and Al. The molar concentration of Li (+ Na) accounts only for ~ 15% of the charge compensation for Al 3+ substitution of Si 4+. Though H was not measured in this study, these data indicate a major role of H in charge balancing Al 3+. The samples belong to the same stratigraphic unit and have similar petrography, but show considerable variability in absolute trace element concentrations between different wells. This variability does not correlate with either sample depth or temperature and shows no regional pattern, but seems to reflect petrophysical and tectonic differences within the sedimentary basin. Petrographic observations of the cogenetic mineral assemblages and hydrochemical modelling indicate that a change from the equilibrium assemblage quartz–kaolinite (–dolomite) to quartz–illite (–dolomite) reflects a decrease in the CO 2 concentration and concurrent variations of the Al concentration. It is concluded that changes in the CO 2 concentrations are responsible for fluctuations in fluid Al concentrations and thus likely also in the investigated quartz cements.