Considering pressures of trade war and geopolitical risk (GPR) on environmental deterioration by affecting countries’ energy mix choices and environmental policies, this study investigates the nexus between energy generation sources and the environment while considering trade policy uncertainty (TPU) and GPR. In this vein, the research uses carbon dioxide (CO2) emissions as an environmental indicator, considers main electricity generation (EG) types as explanatory variables, analyzes the USA and China, and performs the KRLS approach on daily data between 1st January 2019 and 31st July 2025. The study suggests that (i) fossil EG increases CO2 emissions across all percentiles in the USA and China; (ii) renewable EG and GPR decreases CO2 emissions across lower percentiles in the USA, renewable EG and GPR reduces CO2 emissions across lower & middle percentiles in China; (iii) TPU reduces CO2 emissions across lower percentiles in the USA and China, whereas there is an increasing impact across higher percentiles; (iv) the interaction between TPU and GPR has an increasing (insignificant) impact in the USA (China). Overall, the study concludes that fossil EG is harmful, renewable EG is partially beneficial, low-level TPU and GPR are advantageous, and the interaction between TPU and GPR is not effective on CO2 emissions. So, considering that low levels of TPU and GPR make it easier to make good eco-friendly decisions on energy mix choices and high levels increase the tendency to make easy and short-term focused decisions, the countries need comprehensive environmental policies so that they can consider the aforementioned underlying mechanism.