In this paper we investigate the mechanisms that shape the gender wage gap and provide a clear measure of the impact of the allocation of workers to firms and to jobs. We find that one fifth of the gender gap results from segregation of workers across firms and another fifth from job segregation. We also conclude that the “glass ceiling effect” operates mainly through worker allocation to firms rather than occupations. Our approach combines the estimation of a wage equation with high-dimensional fixed effects with Gelbach’s (2009) unambiguous decomposition of the conditional gap. This approach may prove equally useful in applications to other problems in economics.