In this work, the corrosion inhibition of carbon steel in 1 molar HCl solution was evaluated by experimental and modeling approaches using 2-mercaptobenzimidazole (2-MBI). To this end, an experimental design for the weight loss method using response surface methodology (RSM) was carried out and the corrosion rate (CR) and inhibition efficiency (IE) were determined. The study was completed at various values of temperature, exposure time, and inhibitor concentration to determine the optimal conditions for corrosion prevention. Using experimental data on the corrosion rate and inhibition efficiency of 2-MBI, new models were developed, the significance of which was tested using ANOVA-analysis of variance. The developed RSM-based CR and IE models were highly accurate and reliable, and their P-values were less than 0.0001. The novelty of this study lies in the newly developed model for the evaluation of 2-MBI inhibition performance and its application to high-temperature conditions in the petroleum industry. Besides, the R2-statistics (R2, adjusted-R2, and predicted-R2), adequate precision and diagnostic plots were used as main measures to verify the accuracy and adequacy of both CR and IE models. In addition, it was observed that inhibitor concentration had the most impact on both CR and IE models compared to other parameters due to its largest F-values (561.65 for CR and 535.56 for IE models). Moreover, the results indicated that adding 140–150 ppm of 2-MBI at low-level temperatures of 30–35 °C had the most interaction effect on the performance of the corrosion inhibition process. In this case, the CR was less than 0.9 mm/y and the IE more than 94%, even after a high exposure time of 105 h. Furthermore, numerical optimization of the corrosion inhibition process for 2-MBI showed that the optimum conditions for maximum IE and minimum CR were achieved at a concentration of 115 ppm, temperature of 30.7 °C, and exposure time of 60.4 h. Under these conditions, the efficiency and corrosion rate were 92.76% and 0.53 mm/y, respectively. Finally, the adsorption of 2-MBI on the sample surface was studied at various exposure times and temperatures. In all cases, the adsorption behavior obeyed the Langmuir isotherm. In this case, the Gibbs adsorption free energy varied from − 33 to − 37 kJ/mol, which reflects both physical and chemical adsorption of the corrosion inhibitor at all tested temperatures and test times.