This paper studies the relationship between immigration and offshoring by examining whether an in ux of foreign workers reduces the need for firms to relocate jobs abroad. We exploit a Danish quasi-natural experiment in which immigrants were randomly allocated to municipalities using a refugee dispersal policy and we use the Danish employer-employee matched data set covering the universe of workers and firms over the period 1995-2011. Our findings show that an exogenous in ux of immigrants into a municipality reduces firmlevel offshoring at both the extensive and intensive margins. The fact that immigration and offshoring are substitutes has important policy implications, since restrictions on one may encourage the other. While the multilateral relationship is negative, a subsequent bilateral analysis shows that immigrants have connections in their country of origin that increase the likelihood that firms offshore to that particular foreign country.