The impact of geopolitical risks (GPR) on enterprises is significant, yet the existing literature lacks a comprehensive understanding of how GPR affects environmental, social, and governance (ESG) performance. This study addresses this gap by analysing data from Chinese enterprises over the period 2009 to 2021. It empirically examines the impact of GPR on ESG performance and explores the underlying mechanisms. Specifically, the analysis considers the roles of investor attention and government subsidies as moderating factors. The results indicate that GPR inhibits corporate ESG performance. State-owned enterprises are found to mitigate these adverse effects, while privately-owned enterprises tend to exacerbate them. Mechanism tests reveal that GPR negatively impacts ESG performance by increasing financing constraints and reducing financial performance. Furthermore, increased investor attention and government subsidies can alleviate the negative effects of GPR on ESG performance. These findings offer valuable insights for organisations, governments, and stakeholders, enabling them to better respond to GPR and achieve sustainable development.