We document that expansionary monetary policy shocks are less effective at stimulating output and investment in periods of high volatility compared to periods of low volatility, using a regime-switching vector autoregression. The lower effectiveness of monetary policy can be linked to weaker responses of credit costs, suggesting a financial accelerator mechanism that is weaker in high volatility periods. To rationalize our robust empirical results, we use a macroeconomic model in which banks endogenously choose their capital structure. In the model, the leverage choice of banks depends on the volatility of aggregate shocks. In low volatility periods, banks lever up, which makes their balance sheets more sensitive to aggregate shocks and the financial accelerator more effective. On the contrary, in high volatility periods banks decrease leverage, which renders the financial accelerator less effective; this in turn decreases the ability of monetary policy to improve funding conditions and credit supply, and thereby to stimulate the economy.