Credit spreads display occasional spikes and are more strongly countercyclical in times of financial stress. Financial crises are extreme cases of this nonlinear behavior, featuring deep recessions and sharp losses in bank equity. We develop a macroeconomic model with a banking sector in which banks' leverage constraints are occasionally binding and equity issuance is endogenous. The model captures the nonlinearities in the data and produces quantitatively realistic crises. Endogenous equity issuance makes crises infrequent but does not prevent them altogether. Macroprudential policy designed to enhance banks' incentive to issue equity lowers the probability of a crisis and increases welfare.