This paper studies optimal discretionary monetary and fiscal policy when the lower bound on nominal interest rates is occasionally binding in a model with nominal rigidities and long-term government debt. At the lower bound it is optimal for the government to temporarily reduce debt. This decline stimulates output, which is inefficiently low during liquidity traps, by lowering expected real interest rates following the lift-off of the nominal rate from the lower bound. Away from the lower bound, the long-run level of government debt increases with the risk of reaching the lower bound. The accumulation of debt pushes up inflation expectations so as to offset the opposite effect due to the lower bound risk.