We study the gains from trade in a model with endogenously variable markups. We show that the pro-competitive gains from trade are large if the economy is characterized by (i) extensive misallocation, i.e., large inefficiencies associated with markups, and (ii) a weak pattern of cross-country comparative advantage in individual sectors. We find strong evidence for both of these ingredients using producer-level data for Taiwanese manufacturing establishments. Parameterizations of the model consistent with this data thus predict large pro-competitive gains from trade, much larger than those in standard Ricardian models. In stark contrast to standard Ricardian models, data on changes in trade volume are not sufficient for determining the gains from trade.