This study addresses whether the positive consequences of corporate innovation can mitigate the negative repercussions of earning management practices on corporate sustainability. Specifically, it investigates the impact of real earning management (REM) practices on corporate environmental, social and governance (ESG) performance. Likewise, it explores the mediating role of corporate innovation inputs and outputs in this relationship. The study uses a sample of the A‐share listed firms in the Chinese stock market from 2011 to 2021. We measure REM activities as a comprehensive index of corporate abnormal cash flows, abnormal production costs and abnormal discretionary expenses. The Chinese firms' ESG performance is based on Huazheng's ESG rating. Corporate innovation is categorised into innovation input (i.e., R&D expenditure) and innovation output (i.e., patent applications). The study finds that REM practices inversely affect corporate ESG performance and its various pillars. Likewise, firms that engage in higher REM practices are less likely to allocate resources to innovation (i.e., lower R&D expenditure) and have a low innovation output (i.e., fewer patent applications). Nevertheless, firms with higher innovation input and/or higher innovation output exhibit higher ESG performance. Finally, the corporate innovation input and output mediate the relationship between REM practices and ESG performance, suggesting that the positive influence of innovation on ESG performance helps to mitigate the negative consequences of earnings management practices. These results underscore the significance of ethical financial practices and innovation‐driven strategies in enhancing corporate ESG performance.