Numerous studies across different research fields have shown that both male and female referees consistently give higher scores to work done by men than to identical work done by women1,2,3. In addition, women are under-represented in prestigious publications and authorship positions4,5 and women receive ~10% fewer citations6,7. In astronomy, similar biases have been measured in conference participation8,9 and success rates for telescope proposals10,11. Even though the number of doctorate degrees awarded to women is constantly increasing, women still tend to be under-represented in faculty positions12. Spurred by these findings, we measure the role of gender in the number of citations that papers receive in astronomy. To account for the fact that the properties of papers written by men and women differ intrinsically, we use a random forest algorithm to control for the non-gender-specific properties of these papers. Here we show that papers authored by women receive 10.4 ± 0.9% fewer citations than would be expected if the papers with the same non-gender-specific properties were written by men.