Resumen del documento: Infrequent but turbulent episodes of outright sovereign default on domestic creditors are considered a "forgotten history" in Macroeconomics. We propose a heterogeneous- agents model in which optimal debt and default on domestic and foreign creditors are driven by distributional incentives and endogenous default costs due to value of debt for self-insurance, liquidity and risk-sharing. The government's aim to redistribute resources across agents and through time in response to uninsurable shocks produces a rich dynamic feedback mechanism linking debt issuance, the distribution of government bond holdings, the default decision, and risk premia. Calibrated to Spanish data, the model is consistent with key cyclical co-movements and features of debt-crisis dynamics. Debt exhibits protracted fluctuations. Defaults have a low frequency of 0.93 percent, are preceded by surging debt and spreads, and occur with relatively low external debt. Default risk limits the sustainable debt and yet spreads are zero most of the time.