The existing literature has paid less attention to the key role of FDI in the realization of Porter’s hypothesis. Based on China’s provincial panel data from 2007 to 2020, this paper uses the SBM function and the Luenberger productivity index to measure the green total factor productivity (GTFP) of China’s provinces while considering energy consumption and undesired output. Using FDI as the mediating variable and threshold variable, this paper studies the relationship between environmental regulation (ENV), FDI, and GTFP. The research results show that: (1) There is a U-shaped relationship between ENV and GTFP. China is currently on the left side of the U-shaped inflection point. Further improving the intensity of ENV can promote the growth of GTFP. (2) The mediating effect of FDI is significantly established. ENV and FDI show a significant U-shaped relationship. Further development of FDI can promote GTFP. (3) FDI has a threshold effect. When FDI is at a low level of development, ENV and GTFP are negatively correlated and insignificant; when FDI is at a high level of development, ENV can significantly promote the growth of GTFP. The marginal effect on green TFP increases with FDI growth. The results of this paper show that FDI is a necessary prerequisite for the Porter hypothesis to become a reality in China. The research of this paper has important reference value for realizing the sustainable development of environment, economy, and society.