The structural gravity model is the workhorse model in international trade to estimate the drivers of trade costs. We propose a new gravity estimation procedure that allows us to disentangle exogenous trade costs and endogenous aggregate markups under oligopoly. Our method can be easily implemented in standard gravity data sets, and we illustrate it by analyzing the competition and welfare effects of the European Single Market. We find that abolishing the European Single Market would increase domestic aggregate markups in EU member countries by 2 to 6 percent. Welfare effects of trade liberalization are larger due to changes in competition among domestic and foreign firms. Our findings highlight that evaluations of trade policy changes and trade cost reductions should also consider their effects on competition.