I investigate the effects of population ageing on immigration policies. Voters' attitude towards immigrants depends on how the net gains from immigration are divided up in the society by the fiscal policy. In the theoretical literature this aspect is treated as exogenous to the political process because of technical constraints. This generates inconsistent predictions about the policy outcome. I adopt a new equilibrium concept for voting models to analyse the endogenous relationship between immigration and fiscal policies and solve this apparent inconsistency. I show that the elderly and the poor have a common interest in limiting immigration and in increasing public spending. This exacerbates the effects of population ageing on public finances and results in a high tax burden on working age individuals and further worsens the age profile of the population. Moreover, I show that if the share of elderly population is suffciently large, then a society is unambiguously harmed by the tightening in the immigration policy caused by the demographic change. The implications of the model are consistent with the patterns observed in UK attitudinal data and in line with the findings of the empirical literature about migration.