We explain a counterintuitive empirical finding: Firms facing more import competition do more innovation. In our model, factors are trapped inside a firm. An increase in import competition encourages a firm to innovate by reducing the opportunity cost of inputs. Without trapped factors, trade liberalization leads to a small permanent increase in the worldwide rate of growth. With trapped factors, firms that face more import competition do relatively more innovation. The extra innovation induced by trapped factors induces a small permanent increase in aggregate output, consumption, and welfare, generalizing the appropriate estimate of the gains from trade.