We consider a model in which banking is characterized by asset substitution moral hazard and managerial underprovision of effort in loan monitoring. The privately optimal bank leverage efficiently balances the benefit of debt in providing the discipline to ensure that the bank monitors its loans against the benefit of equity in attenuating asset-substitution moral hazard. However, when correlated bank failures impose significant social costs, regulators bail out bank creditors. Anticipation of this action generates multiple equilibria, including an equilibrium featuring systemic risk, in which all banks choose inefficiently high leverage to fund correlated, excessively risky assets. Leverage can be reduced via a minimum equity capital requirement, which can rule out asset substitution, but this also compromises debt discipline. Optimal capital regulation requires a two-tiered capital requirement, with a part of bank capital invested in safe assets, unavailable to creditors upon failure so as to retain market discipline, and made available to shareholders only contingent on solvency in order to contain risk-taking. We also consider a dynamic state-contingent bailout policy in which, rather than always bailing out all banks, the regulator optimally bails out banks only when a sufficiently large number of banks have failed. Used in conjunction with the two-tiered capital requirement proposed, this can contribute to both ex ante and ex post banking stability.