This paper uses the data of Chinese A-share listed companies from 2012 to 2022 to systematically analyze the impact of foreign shareholding on corporate ESG performance. The findings show that foreign shareholding has a positive contribution to corporate ESG performance, and as the proportion of foreign shareholding increases, the performance of corporate ESG performance improves accordingly. In addition, foreign ownership further enhances corporate ESG performance through the mediating variable of increasing analyst attention. In particular, this positive effect is more significant in non-state-owned firms.