In an effort to reduce the STEM gender gap, policymakers often propose providing women with close mentoring by female scientists. This is based on the idea that female scientists might act as role models and counteract negative gender stereotypes that are pervasive in science fields. However, as of yet, there is still no clear evidence on the role of mentor or advisor gender in reducing the STEM gender gap. We use rich administrative data from a private 4-year college to provide some of the first causal evidence on the impact of advisor gender on women's STEM degree attainment. We exploit a unique setting where students are randomly assigned to academic advisors--who are also faculty members--in their freshman year of college. We find that being matched to a female rather than a male science advisor substantially narrows the gender gaps in STEM enrollment and graduation, with the strongest effects occurring among students who are highly skilled in math. In contrast, the gender of an advisor from a non-science department has no impact on students' major choice. Our results indicate that providing close mentoring or advising by female scientists can play an important role in promoting women's participation and persistence in STEM fields.