The challenge of balancing economic and social benefits has emerged as a critical issue for corporate sustainable development. Environmental, social, and governance (ESG) criteria are key considerations for enterprises aiming to enhance both social and economic benefits simultaneously. Based on the upper echelons theory, differences in cognitive foundations and values brought about by top management team heterogeneity can influence corporate decisions. Taking A-share listed companies in China from 2011 to 2022 as samples, we construct a two-way fixed-effects model by firm and year to explore the impact of top management team heterogeneity on corporate ESG performance, and we introduce top management incentives as a moderating variable to further analyze the underlying mechanisms. Our results demonstrate that the gender heterogeneity, functional background heterogeneity, and overseas background heterogeneity of top management teams have significant positive impacts on corporate ESG performance, and monetary compensation incentives and control incentives to top management teams play a positive moderating role, while equity incentives exhibits a negative moderating effect. These findings remain robust across alternative measures of corporate ESG ratings and monetary and control incentives, and through the SYS-GMM model test and instrumental variable approach to address endogeneity. This research contributes to the literature on corporate ESG by validating and extending the understanding of how top management team characteristics affect organizational outcomes, and it provides practical guidance for enhancing corporate ESG practices. The implications of this study suggest that to enhance corporate ESG performance, enterprises should prioritize the promotion of top management team heterogeneity and tailor their incentive mechanisms accordingly.