In the era where environmental, social, and governance (ESG) practices are critical for corporate sustainability and long-term competitiveness, understanding the drivers of ESG performance remains a pressing challenge. While CEOs' key role in shaping organizational strategies, little is known about how the diversity of their functional experiences influences ESG outcomes. To fill the gap, this study draws on upper echelons theory, managerial entrenchment thesis, and role theory to explore how CEO functional experience diversity impacts ESG performance. Utilizing a dataset of Chinese listed companies from 2010 to 2022 and employing OLS, PSM, and Heckman two-step regression models, we find that CEOs with diverse functional experiences enhance ESG performance. However, the positive relationship is moderated by contextual factors:CEO-board friendship ties within firms weaken the association, while heightened media attention strengthens it. Furthermore, the effect is more pronounced in manufacturing firms and non-SOEs, where CEOs demonstrate greater motivation and competence to drive ESG initiatives. By exploring how CEO functional diversity affects firms' ESG performance and contingencies moderating the effect, this study advances theoretical understanding and provides actionable insights for improving ESG performance from the perspective of strategic leadership.