We illustrate a new source of comparative advantage that is generated by countries’ different ability to adjust to technological change. Our model introduces substitution of workers in codifiable (routine) tasks with more efficient machines, a process extensively documented in the labor literature, into a canonical 2 × 2 × 2 Heckscher-Ohlin model. Our key hypothesis is that labor reallocation across tasks is subject to frictions, the importance of which varies by country. The arrival of capital-augmenting innovations triggers the movement of workers out of routine tasks, and countries with low labor market frictions become relatively abundant in non-routine labor. In the new equilibrium, more flexible countries specialize in producing goods that use non-routine labor more intensively. We document empirically that the ranking of countries with respect to the routine intensity of their exports is strongly related to labor market institutions and to cultural norms that influence adjustment to technological change, such as risk aversion or long-term orientation. The explanatory power of this mechanism for trade flows is especially strong for intra-EU trade.