This paper studies systemic risk in the interbank market. We first establish that in the German interbank lending market, a few large banks intermediate funding flows between many smaller periphery banks and that shocks to these intermediary banks in the financial crisis spill over to the activities of the periphery banks. We then develop a network model in which banks trade off the costs and benefits of link formation to explain these patterns. The model is structurally estimated using banks’ preferences as revealed by the observed network structure in the precrisis period. It explains why the interbank intermediation arrangement arises, estimates the frictions underlying the arrangement, and quantifies how shocks are transmitted across the network. Model estimates based on precrisis data successfully predict changes in network-links and in lending arising from the crisis in out-of-sample tests. Finally, we quantify the systemic risk of a single intermediary and the impact of ECB funding in reducing this risk through model counterfactuals.