This article develops a search model of the labor market with matching, bargaining, and employers' taste discrimination in which—under necessary but standard distributional assumption—it is possible to separately identify gender discrimination and unobserved productivity differences. The equilibrium shows that both prejudiced and unprejudiced employers wage discriminate. Maximum likelihood estimates on CPS data indicate that half of the employers are prejudiced, average female productivity is 6.5% lower, and two-third of the gender earning differential may be explained by prejudice. An affirmative action policy is implemented resulting in a redistribution of welfare from men to women at no cost for employers' welfare.