Summary: Girls choose advanced matriculation electives in science and mathematics almost as frequently as boys, in Israel, but are very much under-represented in physics and computer science, and over-represented in biology and chemistry. We test the hypothesis that these patterns stem from differences in mathematical ability. Administrative data on two half-cohorts of Israeli eighth-grade students in Hebrew-language schools links standardized test scores in mathematics, science, Hebrew and English to their subsequent choice of matriculation electives. It shows that the gendered choices they make remain largely intact after conditioning on prior test scores, indicating that these choices are not driven by differences in perceived mathematical ability, or by boysâ€™ comparative advantage in mathematics. Moreover, girls who choose matriculation electives in physics and computer science score higher than boys, on average. Girls and boys react differently to early signals of mathematical and verbal ability; and girls are less adversely affected by socioeconomic disadvantage.