The corrosion-inhibition efficiency of N-decyl-1,2,4-triazole, N-undecyl-1,2,4-triazole, and N-dodecyl-1,2,4-triazole surfactants and the corresponding protonated molecules have been studied computationally using density functional theory and second-order Møller–Plesset calculations. Corrosion-inhibition properties and the strength of the affinity of the iron-surfactant molecules were estimated by using an appropriate cluster model. The iron-surfactant complexes were constructed by attaching the triazole ring to the iron surface modeled by one and five iron atoms, respectively. Relations between molecular properties and corrosion-inhibition efficiency were determined by using linear regression and quantitative structure–activity relationship (QSAR). The QSAR analysis yielded significant correlations between the corrosion-inhibition activity of the studied molecules with molecular properties such as the highest occupied molecular orbital, the lowest unoccupied molecular orbital, dipole moments (μ), and the total atomic charges. Fukui indexes were also calculated for assessing correlations between them and experimental corrosion-inhibition efficiencies. Solvent effects were investigated by using the polarized continuum model. The effects of the acidity medium and the local reactivity of the triazole derivatives with iron were also analyzed. The calculated binding energy of 276 kJ/mol for the Fe5-N-dodecyl-1,2,4-triazole cluster shows that the surfactant molecules bind strongly to iron surfaces, which is in agreement with experimental data. © 2012 Wiley Periodicals, Inc.