This paper develops a theory of capital structure based on the attempts of a firm to alleviate a holdup problem that arises in its bilateral relationship with a buyer. It is shown that by issuing debt to outsiders, the firm can improve its ex post bargaining position vis-a-vis the buyer and capture a larger share of the ex post gains from trade. Debt, however, is costly because the buyer may find the required price too high and refuse to trade. Since debt raises the payoff of claimholders, it strengthens the firm’s incentive to make relationship-specific investments, and therefore alleviates the well-known underinvestment problem. A comparative static analysis yields a number of testable hypotheses regarding the firm’s financial strategy.