Considering the opening of high-speed railway (HSR) as a quasi-natural experiment, this paper explores the emission reduction effect of HSR opening and its mechanisms and heterogeneity characteristics based on the panel data of 272 cities in China from 2006 to 2019 by staggered DID model and the mediating effect model. It is found that (1) the opening of HSR significantly reduces the carbon emission level of cities, and the conclusion still holds after controlling the endogeneity issue and a series of robustness tests; (2) Bancon decomposition and negative weight diagnostics both show that the estimated average treatment effect bias is small and the robust estimators are more robust; (3) by reducing production costs and promoting inter-regional industrial division of labor, the opening of HSR promotes intra-industrial structural transformation and inter-industrial structural transformation, respectively, thus reducing urban carbon emissions. At the same time, HSR achieves urban carbon emission reduction by promoting free movement of population and human capital agglomeration; and (4) further study finds that there is regional heterogeneity in the emission reduction effect of HSR opening, and the carbon reduction effect is mainly reflected in large and medium-sized cities, near provincial capitals, non-resource-based cities, and cities with rich educational resources, which indicates that the location of future HSR should be combined with the city's own characteristics and be tailored to the city.