Acid–base chemistry of clay minerals is central to their interfacial properties, but up to now a quantitative understanding on the surface acidity is still lacking. In this study, with first principles molecular dynamics (FPMD) based vertical energy gap technique, we calculate the acidity constants of surface groups on (0 1 0)-type edges of montmorillonite and kaolinite, which are representatives of 2:1 and 1:1-type clay minerals, respectively. It shows that triple bond; length of mdashSi–OH and triple bond; length of mdashAl–OH2OH groups of kaolinite have pKas of 6.9 and 5.7 and those of montmorillonite have pKas of 7.0 and 8.3, respectively. For each mineral, the calculated pKas are consistent with the experimental ranges derived from fittings of titration curves, indicating that triple bond; length of mdashSi–OH and triple bond; length of mdashAl–OH2OH groups are the major acidic sites responsible to pH-dependent experimental observations. The effect of Mg substitution in montmorillonite is investigated and it is found that Mg substitution increases the pKas of the neighboring triple bond; length of mdashSi–OH and triple bond; length of mdashSi–OH2 groups by 2–3 pKa units. Furthermore, our calculation shows that the pKa of edge triple bond; length of mdashMg–(OH2)2 is as high as 13.2, indicating the protonated state dominates under common pH. Together with previous adsorption experiments, our derived acidity constants suggest that triple bond; length of mdashSi–O– and triple bond; length of mdashAl–(OH)2 groups are the most probable edge sites for complexing heavy metal cations.