This paper examines the microstructure of import markets and the division of the gains from trade among consumers, importers and exporters. When exporters and importers transact through anonymous markets, double marginalization and business stealing among competing importers lead to lower profits. Trading parties can overcome these inefficiencies by investing in richer contractual arrangements such as bilateral contracts that eliminate double marginalization and joint contracts that also internalize business stealing. Introducing these contractual choices into a trade model with heterogeneous exporters and importers, we show that trade liberalization increases the incentive to engage in joint contracts, thus raising the profits of exporters...