We introduce public debt in a Ramsey model with heterogeneous agents and a public spending externality affecting utility which is financed by income tax and public debt. We show that public debt considered as a fixed portion of GDP can have a stabilizing or destabilizing effect, depending on some fundamental elasticities. When the public spending externality is weak and the elasticity of capital-labor substitution is low enough, public debt can only be destabilizing, generating damped or persistent macroeconomic fluctuations. However, when the public spending externality and the elasticity of capital-labor substitution are strong enough, public debt can be stabilizing, driving to monotone convergence an economy experiencing damped or persistent fluctuations without debt.