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