We estimate the causal effect of immigrants’ legal status on criminal behavior exploiting exogenous variation in migration restrictions across nationalities driven by the last round of the European Union enlargement. Unique individual-level data on a collective clemency bill enacted in Italy five months before the enlargement allow us to compare the post-release criminal record of inmates from new EU member countries with a control group of pardoned inmates from candidate EU member countries. Difference-in-differences in the probability of re-arrest between the two groups before and after the enlargement show that obtaining legal status lowers the recidivism of economically motivated offenders, but only in areas that provide relatively better labor market opportunities to legal immigrants. We provide a search-theoretic model of criminal behavior that is consistent with these results.