This paper explores the role of cultural attitudes towards women in determining math educational gender gaps using the epidemiological approach. To identify whether culture matters, we estimate whether the math gender gap for each immigrant group living in a particular host country (and exposed to the same host country's laws and institutions) is explained by measures of gender equality in the parents' country of ancestry. We find that the higher the degree of gender equality in the country of ancestry, the higher the performance of second-generation immigrant girls relative to boys. This result is robust to alternative specifications, measures of gender equality and the inclusion of other human development indicators in the country of ancestry. The transmission of culture is higher among those in schools with a higher proportion of immigrants or in co-educational schools. Our results suggest that policies aimed at changing beliefs can prove effective in reducing the gender gap in mathematics.