Despite some gains, women continue to be underrepresented in many science, technology, engineering, and math (STEM) fields. Using a national longitudinal dataset of 690 participants born in 1991, we tested whether spatial skills, measured in middle childhood, would help explain this gender gap. We modeled the relation between 4th-grade spatial skills and STEM majors while simultaneously accounting for competing cognitive and motivational mechanisms. Strong spatial skills in 4th grade directly increased the likelihood of choosing STEM college majors, above and beyond math achievement and motivation, verbal achievement and motivation, and family background. Additionally, 4th-grade spatial skills indirectly predicted STEM major choice via math achievement and motivation in the intervening years. Further, our findings suggest that gender differences in 4th-grade spatial skills contribute to womens underrepresentation in STEM majors. RESEARCH HIGHLIGHTS: Using a national longitudinal dataset, we found 4th-grade spatial skills directly predicted STEM college major choice after accounting for multiple cognitive and motivational mechanisms. Strong spatial skills in 4th grade also elevated STEM major choice via enhanced math achievement and motivation in the intervening years. Gender differences in 4th-grade spatial skills contributed to womens underrepresentation in STEM college majors.