Climate change is a critical global concern, and China's carbon emissions trading system (ETS), which was introduced in 2011, has significantly contributed to fostering green innovation. Based on the panel data of 284 cities in China from 2006 to 2020, the study examines the impacts and mechanisms of ETS on green innovation using difference in differences method (DID), mechanism testing models, and moderating effect models, and explores the spillover effects of the policy with the help of spatial Durbin models. The study finds that overall, ETS can significantly promote green innovation, with a more significant incentive effect observed for eastern and western cities and resource cities. In terms of the mechanism of action, ETS promotes green innovation by reducing the scale of foreign investment and improving the quality of foreign investment. Additionally, government environmental attention can significantly and positively regulate the relationship between ETS and green innovation. From a spatial spillover perspective, ETS can significantly enhance green innovation in local cities, but it may also inhibit green innovation in neighboring cities. The findings of this study hold significant implications for expediting the transition towards a green economy and promoting sustainable development.