Background: The global increase in Environmental, Social, and Governance (ESG)-based investments has not only reflected companies’ strategic commitments to sustainability but has also been shaped by regulatory pressures and cross-border institutional conditions. Objective: This study aims to examine the influence of external and internal risks on ESG performance through the mediating role of financial performance in non-financial companies across Organisation for Economic Co-operation and Development (OECD) and BRICS countries. External risk is measured using market beta, whereas internal risk is measured through operating cash flow volatility. Methods: This study employed a quantitative approach using fixed-effects panel data analysis of non-financial companies during the 2016–2024 period. Mediation analysis was conducted using bias-corrected bootstrap estimation, while endogeneity was addressed using the Two-Stage Least Squares (2SLS) approach. The final sample composition and statistical software employed are reported in the Methods section. Results: The findings indicate that financial performance does not consistently mediate the relationship between risk and ESG performance across all cross-country subsamples. Internal and external risks demonstrate heterogeneous effects across institutional contexts, primarily due to differences in ESG regulations, financial market development, and stakeholder pressures. The mediating effect was relatively stronger among firms in OECD countries. Conclusion: This study confirms that the relationship among risk, financial performance, and ESG performance is context-dependent and cannot be universally generalized without considering country-specific institutional characteristics.