Why do some authoritarian states adopt more restrictive immigration policies than others? Much of the existing literature focuses on the politics of immigration in democracies, despite the presence of large-scale immigration to autocracies. In this article, I argue that the level of electoral competition can be a key factor in immigration policymaking in electoral autocracies. Autocrats who face high levels of electoral competition tend to impose immigration restrictions as a way of mobilizing anti-outgroup sentiment and boosting their own popularity. I test this hypothesis by conducting comparative case studies on Russia and Kazakhstan, both of which are major immigrant-receiving autocracies. Based on the analysis of original data gathered from 11 months of fieldwork in the two countries, I find that the relatively high level of electoral competition in Russia in the 2010s facilitated increased immigration restrictions, while Kazakhstan depoliticized labour immigrants and enacted a de facto open immigration policy in the absence of electoral competition.