This paper considers two firms that engage in joint production. The prospect of repeated interaction introduces dynamics in that actions that firms take today influence the costliness and effectiveness of actions in the future. Repeated interaction also facilitates the use of informal agreements (relational contracts) that are sustained not by the court system, but by the ongoing value of the relationship. We characterize the optimal relational contract in this dynamic system with double moral hazard. We show that an optimal relational contract has a simple form that does not depend on the past history. The optimal relational contract may require that the firms terminate their relationship with positive probability following poor performance. This may occur even when the firms observe an independent signal for the action of each firm that allows them to assign blame. If, however, the buyers action does not influence the dynamics, the need for termination is eliminated. The paper applies the method to the issue of sequential versus parallel collaborative product development.