As an important representative of new productive forces, artificial intelligence (AI) shows great potential in promoting the optimal allocation of factors and driving green transformation. Based on the panel data of 298 prefecture-level cities in China from 2012 to 2022, this paper constructs a panel regression to test the effect and mechanism of AI on pollution reduction and carbon emission reduction. The results show that AI significantly promotes urban pollution reduction and carbon emission reduction, and this conclusion is verified under different model settings and robustness tests. In addition, AI indirectly affects pollution reduction and carbon emission reduction through three paths: optimizing factor structure, accelerating factor circulation, and improving factor efficiency, among which the mechanism of enhancing green total factor productivity is the most significant. The marginal contribution of this paper lies in revealing the systematic mechanism of AI acting on pollution reduction and carbon emission reduction from the perspective of multiple factors, expanding the existing research perspectives on environmental governance and technological progress. The research conclusions have important theoretical value and practical enlightenment for AI empowering green development.