• ESG performance substantially reduces opportunistic EM behavior of firms. • Civil law code and superior creditor rights negatively moderate the ESG-EM relationship. • ESG engagement creates the trust and support for the firm in the eyes of stakeholders and therefore they accept the firm's performance and strategies and ensure the continuity of the firm alleviating the need to manipulate actual earnings. This study examines whether environmental, social, and governance (ESG) engagement affects firms’ earnings management (EM) behavior in a multicountry set up. Employing the Tobit and panel regression framework and co`nsidering performance-matched measure of EM, we show that ESG performance substantially reduces opportunistic firms’ EM behavior. Moreover, the civil law code and superior credit rights negatively moderate the ESG–EM relationship. Empirical findings are robust and survive the use of alternative methodology and endogeneity test.