I build a dynamic capital structure model that demonstrates how business cycle variation in expected growth rates, economic uncertainty, and risk premia influences firms' financing policies. Countercyclical fluctuations in risk prices, default probabilities, and default losses arise endogenously through firms' responses to macroeconomic conditions. These comovements generate large credit risk premia for investment grade firms, which helps address the credit spread puzzle and the under-leverage puzzle in a unified framework. The model generates interesting dynamics for financing and defaults, including market timing in debt issuance and credit contagion. It also provides a novel procedure to estimate state-dependent default losses.