Research on the relationship between competition and innovation often yields mixed findings, which may stem from insufficient attention to the institutional contexts. To reconcile the debate, we employ an institutional lens to examine the role of institutional legitimacy of competition in the foreign-competition-innovation relationship. We conduct a multilevel analysis on a sample of 27,126 firms from 27 developing countries spanning the years 2010 to 2018. The results show that informal institutional legitimacy of competition positively moderates the relationship between foreign competition and product innovation of domestic firms in developing countries, while formal institutional legitimacy of competition plays a less significant role. Additionally, we find that the moderating effect is less pronounced for firms engaged in bribery, as such firms are less embedded in market-oriented institutions.