This paper shows that the cost of enforcing contracts governing non-financial relationships between firms affects a firm's financing structure. We analyze the interaction between a firm's capital structure and the type of contracts it uses to deal with its suppliers. We first develop a theoretical model where a downstream party needs an intermediate good from an upstream party, and this intermediate good can be of high or low quality. Court-enforceable contracts can be used to enforce high quality, but their use is costly. If these costs are too high, relational contracts - self-enforcing informal arrangements that can be sustained in long-term relationships - are needed. Relational contracts, though, can only be sustained if debt is not too high. The reason is that a firm's commitment in relational contracts is determined by its future profits in the cooperative relationship, and the need to repay debt reduces future profits. We therefore derive the prediction that, on average, higher costs of enforcing formal contracts should be associated with firms having less leverage. We test this prediction with the help of two datasets. First, the Microdatabase Directinvestment (MiDi) provided by Deutsche Bundesbank, which records balance-sheet information on the universe of German investments abroad, including detailed information on external debt and equity capital. Second, the World Bank's Doing Business Database, which provides information on the average cost of enforcing (formal) contracts between a firm and a supplier of an intermediate good. Using a panel data model for fractional response variables, we can show that an increase in the cost of enforcing contracts in a country makes firms use substantially more equity financing.