Crashes have fascinated and baffled many canny observers of financial markets. In the strict orthodoxy of the efficient market theory, crashes must be due to sudden changes of the fundamental valuation of assets. However, detailed empirical studies suggest that large price jumps cannot be explained by news and are the result of endogenous feedback loops. Although plausible, a clear-cut empirical evidence for such a scenario is still lacking. Here we show how crashes are conditioned by the market liquidity, for which we propose a new measure inspired by recent theories of market impact and based on readily available, public information. Our results open the possibility of a dynamical evaluation of liquidity risk and early warning signs of market instabilities, and could lead to a quantitative description of the mechanisms leading to market crashes.