This paper investigates the effect of export shocks on innovation. On the one hand a positive shock increases market size and therefore innovation incentives for all firms. On the other hand it increases competition as more firms enter the export market. This in turn reduces profits and therefore innovation incentives particularly for firms with low productivity. Overall the positive impact of the export shock on innovation is magnified for high productivity firms, whereas it may negatively affect innovation in low productivity firms. We test this prediction with patent, customs and production data covering all French manufacturing firms. To address potential endogeneity issues, we construct firm-level export proxies which respond to aggregate conditions in a firm's export destinations but are exogenous to firm-level decisions. We show that patenting robustly increases more with export demand for initially more productive firms. This effect is reversed for the least productive firms as the negative competition effect dominates.