We empirically examine the relationship between immigration and votes for the Alternative für Deutschland (AfD) in the 2017 German parliamentary election. We conduct a cross-sectional analysis, exploiting election results and socio-demographic as well as geographic features of the 401 German administrative districts. We find that immigration has a negative effect on AfD voting. A 1 percentage point increase in the share of foreigners is associated with a decrease in the AfD vote share of up to 0.37 percentage points. The result is robust to several estimation variations, such as addressing the potentially endogenous distribution of foreigners with an instrumental variable analysis.