Sierra de Gádor is a complex, Triassic age aquifer system formed by dolostones and limestones with interbedded gypsum. On top, a thick Neogene-Quaternary series gives rise to shallow aquifers. F-Pb-Zn stratabound deposits are found within the Triassic carbonate formations. Their mineral paragenesis includes sphalerite, galena, pyrite, marcasite, fluorite and barite. The Sierra de Gádor groundwater is the principal water resource for this semiarid environment, and the population is potentially exposed to hazardous elements related to mining activities and wastes. In October 1966, an intensive precipitation event (190 mm day−1) broke several old tailing structures, flooding part of the Berja village with polluted sludge. Fluorine values in some boreholes and springs were found higher than 1.5 mg l−1, the maximum value permitted by Spanish regulation for human consumption. Hydrogeochemistry data, statistical tools and geochemical simulations were used in this study to assess the physicochemical processes and the fluorine sources within this carbonate aquifer. Most of the analysed water samples are close to equilibrium with respect to carbonate minerals but are undersaturated with respect to fluorite and gypsum. About 39% of the samples have fluorine concentration higher than the regulatory limit. A statistical analysis indicates that fluorine has a low correlation with other variables. Inverse and mixing models, performed with the code PHREEQC, differentiate the predominance of water–rock interaction processes within the carbonate aquifer and water mixing between the carbonate and shallow aquifers. The results indicate that some fluorite dissolution must occur in the carbonate Triassic aquifer, whereas the shallow aquifers leach fluorine from mining wastes. Both types of aquifers are interconnected, and their waters mix below the flooded area. There, the high fluorine values appear to have two sources: (i) the regional fluorine enrichment due to the mineralization; and (ii) the polluted 1966 flood that reached the deep carbonates via the shallow aquifer.