We generalize the Antras and Helpman (2004) model of the international organization of production in order to accommodate varying degrees of contractual frictions. In particular, we allow the degree of contractibility to vary across inputs and countries. A continuum of firms with heterogeneous productivities decide whether to integrate or outsource the production of intermediate inputs, and from which country to source them. Final-good producers and their suppliers make relationship-specific investments which are only partially contractible, both in an integrated firm and in an arm's-length relationship. We describe equilibria in which firms with different productivity levels choose different ownership structures and supplier locations, and then study the effects of changes in the quality of contractual institutions on the relative prevalence of these organizational forms. Better contracting institutions in the South raise the prevalence of offshoring, but may reduce the relative prevalence of FDI or foreign outsourcing. The impact on the composition of offshoring depends on whether the institutional improvement affects disproportionately the contractibility of a particular input. A key message of the paper is that improvements in the contractibility of inputs controlled by final-good producers have different effects than improvements in the contractibility of inputs controlled by suppliers.