I develop an open economy model with variable markups to analyze the effect of commodity booms on misallocation. Commodity booms create a real exchange rate appreciation that reallocates resources across firms within the tradable sector. This reallocation occurs for two reasons. First, there is tougher foreign competition on domestic producers (competition channel), which pushes large firms to reduce their markups and small firms to exit. Second, a reduction in the relative cost of imported materials (cost channel) induces large firms, who use them more intensively, to increase their markups. I calibrate the model to Chile and replicate the increase in the price of its main export product (copper) during the early 2000s. I find that there is a substantial reallocation within the tradable sector, which decreases misallocation. Both channels matter quantitatively. Without heterogeneity in the share of imported materials, the decrease in misallocation would be halved. Furthermore, markup dispersion falls more in industries that experience a higher increase in foreign competition. Finally, I estimate markups using Chilean firm-level data and show that the broad patterns are qualitatively consistent with the model predictions.