All OECD countries have either legally mandated severance pay or compensations imposed by industry-level bargaining in case of employer initiated job separations. According to the extensive literature on Employment Protection Legislation such transfers are either ineffective or highly distortionary. In this paper we show that mandatory severance is optimal in presence of wage deferrals when there is moral hazard of employers and workers, notably when employers cannot commit not to fire a non-shirker and shirkers can also get away with it. Our model also accounts for two neglected features of EPL. The first is that dismissal costs depend not only on whether the dismissal is deemed fair or unfair, but also on the nature, economic vs. disciplinary, of the layoff. The second feature is that compensation for unfair dismissal or severance is generally increasing with tenure.