We present a simple and tractable trade model of heterogeneous firms, endogenous quality choice, and endogenous markups. A key feature of the model is that competition not only lowers the cost cut-off between the firms that produce and those that exit, but it also raises the scope for quality differentiation. With both these channels present, the most productive firms respond to competition by raising quality, prices, and markups, while the least productive either exit or respond in the exact opposite manner. The model generates a unified theory and a supply-side explanation for an extremely rich set of stylized facts relating to (i) productivity heterogeneity, (ii) product quality heterogeneity, (iii) markups heterogeneity, (iv) heterogeneity in the response of firms to competition, and (v) heterogeneity in the sign and magnitude of the correlations between output prices, firm productivity, size, and product quality. In addition, the model predicts that average price and markups exhibit a U-shape response to competition and that imports from developed countries have higher quality, markups and prices when compared to imports from developing countries. (C) 2015 Elsevier B.V. All rights reserved.