The digital economy (DE) is emerging as a crucial driver of economic growth and an effective tool for alleviating resource and environmental pressures, thereby evolving into a significant force in facilitating green transformation. This study elaborates on the theoretical mechanism of the impact of DE on green total factor productivity (GTFP), and conducts multidimensional empirical tests using panel data from 284 cities in China. The main findings are as follows: (1) DE exerts significant positive direct, indirect, and spatial spillover effects on GTFP, signifying its growing role as a robust driver of GTFP. Notably, technological innovation emerges as a key mediator of DE’s impact on GTFP. (2) The impact of DE on GTFP exhibits a distinct pattern: initially pronounced, gradually diminishing, and then rebounding as DE progresses. (3) DE tends to exacerbate, rather than alleviate, the development divide and resource curse, especially in underdeveloped and resource-rich cities where its benefits are constrained. (4) Government behavior is pivotal in influencing DE’s impact on GTFP. Supportive policies and strict environmental regulations are critical in harnessing DE’s positive contributions to GTFP. This study lays a scientific foundation for leveraging the “green attributes” of DE and offers insights into bridging the developmental disparities among cities.