The evidence suggests that relational contracting and legal rules play an important role in credit markets but on the basis of the prevailing field data it is difficult to pin down their causal impact. Here we show experimentally that relational incentives are a powerful causal determinant for the existence and performance of credit markets. In fact, in the absence of legal enforcement and reputation formation opportunities the credit market breaks down almost completely while if reputation formation is possible a stable credit market emerges even in the absence of legal enforcement of debt repayment. Introducing legal enforcement of repayments causes a further significant increase in credit market trading but has only a surprisingly small impact on overall efficiency. The reason is that legal enforcement of debt repayments weakens relational incentives and exacerbates another moral hazard problem in credit markets the choice of inefficient high-risk projects.