This paper develops a model of how the financial system is organized to most effectively create safe assets and analyzes its implications for asset prices, capital structure, and macroeconomic policy. In the model, financial intermediaries choose to invest in the lowest risk assets available in order to issue safe securities while minimizing their reliance on equity financing. Although households and intermediaries can trade the same assets, in equilibrium all debt securities are owned by intermediaries since they are low risk, while riskier equities are owned by households. The resulting market segmentation explains the low risk anomaly in equity markets and the credit spread puzzle in debt markets and determines the optimal leverage of the non-financial sector. An increase in the demand for safe assets causes an expansion of the financial sector and extension of riskier credit to the non-financial sector- a subprime boom. Quantitative easing increases the supply of safe assets, leading to a compression of risk premia in debt markets, a deleveraging of the non-financial sector, and an increase in output when monetary policy is constrained. In a quantitative calibration, the segmentation of debt and equity markets is considerably more severe when intermediaries are poorly capitalized.