This paper studies the public sector wage gap in Spain, by gender, skill level and type of contract, using recent administrative data from tax records. We estimate wage distributions in the presence of covariates separately for men and women in the public and in the private sectors, and we take advantage of the longitudinal structure of the data to control for selection. We nd a positive public wage premium for men and women even after accounting for characteristics and endogenous selection; the observed average gap in hourly wages of 35 log points is reduced to 20 when accounting for observed characteristics, and to 10 once endogenous selection is also taken into consideration. We also nd substantial variation in the public premium along the wage distribution once observed characteristics are accounted for. This variation, however, is oset by opposite patterns of selection into the public sector: while we observe positive selection into the public sector at the bottom of the wage distribution, workers at the top of the distribution select negatively into the public sector. Joint with Laura Hospido (Banco de Espana and IZA).