This article estimates a general credit risk model with both macroeconomic and latent credit factors for Spanish banks during the period 2004-2010. The proposed framework allows to estimate with bank level data both the standard credit risk model of Basel II and generalized models. I fi nd evidence of persistence in the credit latent factor and of a signifi cant effect of GDP growth and interbank rates on loan default rates. The estimated default correlation is low across specifications. The model is also used to calculate the impact on the probabilities of default of stressed economic scenarios.