We analyze the welfare effects of trade and migration, focusing on two-sided horizontal heterogeneity among workers and firms. Horizontal (skill-type) heterogeneity among workers generates monopsonistic labor markets as well as within-firm wage inequality and an endogenous quality of worker–firm matches. In a model combining horizontal worker heterogeneity with monopolistic competition on goods markets, trade liberalization causes firm exit which raises wage markdowns and worsens the average quality of worker–firm matches. It also increases the degree of income inequality. Yet, aggregate welfare is higher under free trade than under autarky. Integration of labor markets leads to two-way migration between symmetric countries. Liberalizing migration has an ambiguous effect on the quality of worker–firm matches and income inequality, but it leads to lower wage markdowns and lower goods prices and thus to higher welfare in both countries. Our model advocates opening up labor markets simultaneously with trade liberalization.