We develop a DSGE model with a heterogeneous banking sector. We introduce endogenous default probabilities for both firms and banks, and allow for bank regulation and liquidity injections into the interbank market. We aim to understand the interactions between the banking sector and the rest of the economy and the importance of supervisory and monetary authorities in restoring financial stability. The model is calibrated against real US data and used for simulations. The minimum capital requirements of Basel I regulation reduce the long-run level of output but improve the resilience of the economy to shocks, while Basel II capital requirements increase business cycle fluctuations.