PurposeThe purpose of this paper is to investigate whether institutional quality influences the corporate social responsibility (CSR) and firm performance (FP) relationship.Design/methodology/approachThis paper uses a large sample of 814 European firms from roughly 2008 to 2017. In order to resolve the problem of endogeneity and heterogeneity the system generalized method of moment is performed.FindingsFirst, the effect of CSR on FP is simultaneously positive and significant for the economic, social and overall score based on an equal-weighted performance of four CSR pillars. Second, we found that the institutional quality matters, as corruption significantly decreases the FP, while government stability law and order exert a positive impact. Third, results suggest, similarly, that FP benefits from the interactional relationship between CSR and institutional quality. Finally, as for firm specifics, we found that the lagged performance and growth rate of sales significantly increase the European FP. However, FP is negatively sensitive to the leverage ratio.Research limitations/implicationsThis study aims to fill the gap in the CSR-FP interrelation and institutional context. Since we have a large number of firms (814) compared to a relatively small temporal dimension (10 years), the dynamic panel data analysis, and more precisely, the SGMM approach, is the most appropriate to resolve the problem of endogeneity and heterogeneity.Practical implicationsThe institutional environment affects the firm's CSR response and results. The strong institutional quality may result in increased regulatory pressures placed on the firm related to social responsibility compliance and can thereby enhance the CSR–FP relationship.Originality/valueTo the best of our knowledge, this is the first study that explored the relationship between CSR–FP and institutional quality in the European context. Indeed, this paper shows that institutional quality mediates the relationship between CSR practices and FP.