We attempt to explore the impact of ESG (Environmental, Social, and Governance) performance on firms from a comprehensive and peer comparison perspective. We constructed a composite index encompassing profitability, growth, and security, and compared it with the median of peers to ultimately form a quality index for enterprises. Empirical results indicate that ESG performance contributes to improving the quality of firms and exhibits a certain degree of persistence. Among the three components, governance performance has the greatest impact, followed by social performance, while environmental performance is not significant. Mechanism research shows that ESG performance enhances corporate quality by alleviating financing constraints and improving labour productivity. Further analysis reveals that the more ESG investors there are, the weaker the impact of ESG performance on corporate quality; the better the financial fundamentals of a company, the greater the impact of ESG performance on corporate quality; and when firms operate in more competitive market environments, the impact of ESG performance on quality improvement is more pronounced.