We use new theory and data to study how firms endogenously form production networks across regions and countries. Supplier and buyer relationships form depending on firms’ productivity and geographic location. We characterize the normative and positive properties of the spatial distribution of economic activity and welfare in general equilibrium. We calibrate the model using domestic and international firm-to-firm trade data from Chile. Both iceberg trade costs and search and matching frictions are important for aggregate trade flows and production networks. Endogenous formation of production networks leads to larger and more dispersed effects of international and intra-national trade cost shocks.