We incorporate monetary policy into a model of stochastic debt sustainability analysis and evaluate the impact of unconventional policies on sovereign debt dynamics. The model optimizes debt financing to trade off financing cost with refinancing risk. We show that the ECB pandemic emergency-purchase programme (PEPP) substantially improves debt sustainability for euro area sovereigns with a high debt stock. Without PEPP, debt would be on an increasing (unsustainable) trajectory with high probability, while, with asset purchases, it is sustainable and the debt ratio is expected to return to pre-pandemic levels by about 2030. The improvement in debt dynamics extends beyond the PEPP and is larger for more gradual unwinding of the Central Bank balance sheet. Optimal financing under PEPP induces an extension of maturities reducing the risk without increasing costs. The analysis also shows that inflation surprises have relatively little impact on debt dynamics, with the direction and magnitude of the effect depending on the monetary policy response.