This paper analyzes the effect of foreign aid on illegal immigration and host country welfare using a general equilibrium model. It shows that foreign aid may worsen the recipient nation's terms of trade. Furthermore, it may also raise illegal immigration, if the terms of trade effect on immigration flows dominates the other effects identified in our analysis. Empirical analysis of the effect of foreign aid on illegal immigration to the USA broadly supports the predictions of our theoretical model. Foreign aid worsens the recipient's terms of trade. While the terms of trade effect tends to reduce illegal immigration, countervailing effects are found to dominate. The paper contributes to the related literature by establishing that there are unintended consequences of foreign aid and, while some of them are reminiscent of the classical transfer problem, others are new and arise as a result of endogenous illegal immigration flows.