We study the optimal accumulation of international reserves in a quantitative model of sovereign default with long-term debt and a risk-free asset. Keeping higher levels of reserves provides a hedge against rollover risk, but this is costly because using reserves to pay down debt allows the government to reduce sovereign spreads. Our model, parameterized to mimic salient features of a typical emerging economy, can account for a significant fraction of the holdings of international reserves, and the larger accumulation of both debt and reserves in periods of low spreads and high income. We also show that income windfalls, improved policy frameworks, larger contingent liabilities, and an increase in the importance of rollover risk imply increases in the optimal holdings of reserves that are consistent with the upward trend in reserves in emerging economies. It is essential for our results that debt maturity exceeds one period.