We use idiosyncratic variation in gender composition across cohorts within Norwegian lower-secondary schools to analyze the impact of female peers on students grades and choices of STEM subjects. We find that more female peers in lower secondary increases girls probability of choosing STEM-courses in upper secondary, and the effect on choices is larger than the effect on grades. Survey evidence suggests that a potential mechanism is an improved classroom environment. Boys performance is negatively affected by more female peers. They also start upper secondary later and more often choose vocational studies.