We study a general equilibrium model in which firms choose their capital structure optimally, trading off the tax advantages of debt against the risk of costly default. The costs of default are endogenous: bankrupt firms are forced to liquidate their assets, resulting in a fire sale if there is insufficient liquidity in the market. When the corporate income tax rate is zero, the optimal capital structure is indeterminate, there are no fire sales, and the equilibrium is Pareto efficient. When the tax rate is positive, the optimal capital structure is uniquely determined, default occurs with positive probability, firms’ assets are liquidated at fire-sale prices, and the equilibrium is constrained inefficient. More precisely, firms’ investment is too low and, although the capital structure is chosen optimally, in equilibrium too little debt is used. We also show that introducing more liquidity into the system can be counter-productive: although it reduces the severity of fire sales, it also reduces welfare.