We present a model of optimal allocation to liquid and illiquid assets, where illiquidity risk results from the restriction that an asset cannot be traded for intervals of uncertain duration. Illiquidity risk leads to increased and state-dependent risk aversion and reduces the allocation to both liquid and illiquid risky assets. Uncertainty about the length of the illiquidity interval, as opposed to a deterministic nontrading interval, is a primary determinant of the cost of illiquidity. We allow market liquidity to vary from “normal” periods, when all assets are fully liquid, to “illiquidity crises,” when some assets can only be traded infrequently. The possibility of a liquidity crisis leads to limited arbitrage in normal times. Investors are willing to forgo 2% of their wealth to hedge against illiquidity crises occurring once every 10 years.