This paper analyzes immigration and outsourcing in a general-equilibrium model of international factor mobility. In our model, legal immigration of skilled labor is controlled through a quota, while outsourcing is determined both by the firms in response to market conditions and through policy-imposed barriers. A loosening of the immigration quota reduces outsourcing, enriches capitalists, leads to losses for native workers, and raises national income. If the nation targets an exogenously determined immigration level, the second-best outsourcing tax can be either positive or negative. If in addition to the immigration target there is a wage target arising out of income distribution concerns, an outsourcing subsidy is required. We extend the analysis to consider illegal immigration of unskilled labor. A higher legal immigration quota will lead to more (less) illegal immigration if skilled and unskilled labor are complements (substitutes) in production.