We develop a general equilibrium theory of the capital structures of banks and firms. The liquidity services of bank deposits make deposits a "cheaper" source of funding than equity. In equilibrium, banks pass on part of this funding advantage in the form of lower interest rates to firms that borrow from them. Firms and banks choose their capital structures to balance the benefits of debt financing against the risk of costly default. An increase in the equity of a firm makes its debt less risky and that in turn reduces the risk of the banks who lend to the firm. Hence there is some substitutability between firm and bank equity. We find that firms have a comparative advantage in providing a buffer against systemic shocks, whereas banks have a comparative advantage in providing a buÂ¤er against idiosyncratic shocks.