This paper develops a tractable multi-country model of the international banking system where global banks interact with local banks. In the model, consistent with the data, when the leverage of global banks goes up, countries experience both higher gross capital inflows and outflows, and global imbalances increase. I show that the net external position of a country against global banks |its assets on global banks minus its liabilities towards global banks| plays a key role in explaining its macroeconomic response to a change in global financial conditions. The main predictions of the model are borne out in a large panel of advanced and emerging market economies. In particular, countries with higher net external liabilities against global banks tend to experience a larger drop in investment and a larger improvement in their current account balance following a deleveraging by global banks.