We study the effect of elementary school teachers’ beliefs about gender roles on student achievement. We exploit a natural experiment where teachers are prevented from self-selecting into schools, and, conditional on school, students are allocated to teachers randomly. We show that girls who are taught for longer than a year by teachers with traditional gender views have lower performance in objective math and verbal tests, and this effect is amplified with longer exposure to the same teacher. We find no effect on boys. We show that the effect is partly mediated by teachers’ transmitting traditional beliefs to girls.