At present, there are few studies exploring the impact of market-based environmental regulation on ESG performance based on the perspective of carbon emission trading scheme (CETS). This paper aims to supplement this research field through empirical analysis. Taking Shanghai-Shenzhen A-share listed companies from 2012 to 2022 as the research object, this paper studies the impact of CETS, a market-based environmental regulation tool, on the ESG performance of enterprises by constructing a time-varying DID model and examines the mediating roles of green technology innovation, agency cost and analyst attention. The results show that the implementation of CETS can significantly boost ESG performance, and green technology innovation, agency cost, and analyst attention play a partial intermediary role between the two, while the mediating effects of green total factor productivity and green total factor energy efficiency are not significant. In terms of heterogeneity analysis, the study shows that CETS implementation has a more substantial promotion effect on ESG performance in non-state-owned enterprises, non-politically connected enterprises and non-high-tech enterprises. In this paper, the robustness test was carried out through PSM-DID, placebo test and replacement of explained variables, and the test results further supported the hypothesis in this paper. This study enriched the research on the impact of market-based environmental regulation on ESG from the perspective of CETS. It provided enlightenment for enterprises to improve ESG performance to a strategic level, improve the level of green technology innovation, and the government to implement differentiated environmental governance policies.