Two striking facts about international capital flows in emerging economies motivate this paper: (1) Governments hold large amounts of international reserves, for which they obtain a return lower than their borrowing cost. (2) Purchases of domestic assets by nonresidents and purchases of foreign assets by residents are both procyclical and collapse during crises. We propose a dynamic model of endogenous default that can account for these facts. The government faces a trade-off between the benefits of keeping reserves as a buffer against rollover risk and the cost of having larger gross debt positions. Long-duration bonds, the countercyclical default premium, and sudden stops are important for the quantitative success of the model.