The green total factor productivity (GTFP) of industrial enterprises directly affects the transformation and upgrading of China's economy, and environmental regulation (ER) has an important effect on the GTFP of industrial enterprises. However, the research conclusions on the relationship between GTFP and ER are quite different, which can not effectively guide the specific practice. Given this, this study first analyses the direct relationship between ER and GTFP and then studies the mediating effects of technological innovation. Furthermore, from the perspective of heterogeneity, this paper takes technological innovation as the threshold variable and uses the panel threshold model to study the nonlinear dynamic effect of different types of ER on GTFP. The empirical results show that: (1) Both command-and-control ER (CCER) and market-based ER (MBER) have a U-shaped relationship with GTFP; (2) Whether CCER or MBER, technological innovation plays a significant mediating role in the relationship between ER and GTFP; (3) Only when the technological innovation level of enterprises is higher than 14.644, the role of CCER in promoting GTFP will be shown; similarly, only when the technological innovation level of enterprises is higher than 14.751, the role of MBER in promoting GTFP will be shown. The findings show that implement classified regulatory policies, set reasonable ER intensity, increase investment in technological innovation, and optimise the import and export trade structure will help to improve GTFP.