Theories of taste-based discrimination predict that competitive pressures will drive discriminatory behavior out of the market. Using detailed matched employer-employee data, we analyze how firm takeovers and product market competition are related to the gender composition of the firms workforce and the gender wage gap. Using a difference-in-difference framework and dealing with several endogeneity concerns, we find that the share of female employees increases as a result of an ownership change, in particular when product market competition is weak. Further, increased competition reduces the gender wage gap, especially among highly educated employees. While the estimated wage effect is quite small, the results support the main theoretical predictions.