This project analyzes the effect of selection on ability on the evolution of the gender wage gap during the first years of professional life. There is a widely documented pattern of increase in the wage differential across gender in the first years of professional life. Most of the literature has focused on the different accumulation of labor market experience across men and women as a potential explanation, since men typically display higher labor market attachment and fewer exits when compared to women. We point out that, with differential labor market entry and exit across genders, it is also possible that the pool of men and women being compared to each other changes with age. In other words, differential selection across genders is also a potentially relevant factor in explaining the evolution of the gender wage gap during the early career of workers. We use longitudinal data with 16 years of the early career history of formal sector workers in Brazil, which allows us to build a measure of unobserved ability that we use to analyze the dynamics of labor market selection across genders. We focus on the cohort born in 1974, for which we have a close to complete history of formal labor market participation. For this cohort, the average ability of formally employed men improved in relation to that of women during the first years of professional life. The selection of men and women into the labor market was similar at age 21, but by age 31 high-ability men (one standard deviation above the mean) had a probability of employment 1.6 percentage point higher than their high-ability female counterparts. This contributed to the increase in the conditional gender wage gap observed in the early career, as the ability distribution of employed women deteriorated in relation to that of employed men. Our estimates suggest that, for the 1974 cohort, this mechanism explains 32% of the cumulative growth in the conditional gender wage gap between ages 21 and 36.