This paper evaluates the optimality of a temporary worker permit policy from the point of view of the host country by using a two-country dynamic general equilibrium model, calibrated with data from the United States and Mexico. In the model, the decision to migrate and the corresponding decision to return are endogenous and take place within families that are heterogeneous in terms of human capital. After finding a migrant's optimal migration duration and the resulting shrinkage in the wage gap and change in interest rates, the paper derives the restriction on migrants' stay that maximizes natives' utility. It also derives the migrant length of stay that would pass a majority vote. When migration duration is restricted, the fraction of the native population made better off is maximized with a permit length of four years.