I study economies where banks do not fully internalize the social costs of default, which distorts their lending decisions. In all these economies, a common general equilibrium effect leads to aggregate over-investment. As a result, under laissez-faire, crises are too frequent and too costly from a social point of view. In response, the regulator sets a capital requirement to trade off expected output against financial stability. The capital requirement that ensures investment efficiency depends on the state of the economy. Because of the general equilibrium effect, the more aggregate banking capital the tighter the optimal requirement. A regulation that fails to take this effect into account exacerbates economic fluctuations and allows for excessive build-up of risk in the financial sector during booms. Government guarantees amplify this mechanism and, at the peak of a boom, even a small adverse shock can trigger a banking sector collapse, followed by an excessively severe credit crunch.