Internal debt financing can be used by multinational firms to shift profits from high-tax to low-tax countries. Governments apply thin capitalization rules (TCRs), which limit the deductibility of interest expenses, to restrict this behavior. TCRs fall in two main categories: safe haven rules and earnings stripping rules. We derive the locally and the socially optimal type of TCR in a general equilibrium two country model. A unilateral switch from safe haven to earnings stripping rules is welfare improving, because it allows governments to tax at different effective rates domestic and multinational firms. Thus, we provide an explanation for the recently observed trend to replace safe haven rules with earnings stripping rules. Depending on the degree of transfer price manipulation undertaken by multinational enterprises, a prisoner dilemma result emerges, as local governments may have a dominant strategy to choose earnings stripping, even when it is not mutually welfare maximizing.