Women remain significantly underrepresented in the science, engineering, and technology workforce. Some have argued that spatial ability differences, which represent the most persistent gender differences in the cognitive literature, are partly responsible for this gap. The underlying forces at work shaping the observed spatial ability differences revolve naturally around the relative roles of nature and nurture. Although these forces remain among the most hotly debated in all of the sciences, the evidence for nurture is tenuous, because it is difficult to compare gender differences among biologically similar groups with distinct nurture. In this study, we use a large-scale incentivized experiment with nearly 1,300 participants to show that the gender gap in spatial abilities, measured by time to solve a puzzle, disappears when we move from a patrilineal society to an adjoining matrilineal society. We also show that about one-third of the effect can be explained by differences in education. Given that none of our participants have experience with puzzle solving and that villagers from both societies have the same means of subsistence and shared genetic background, we argue that these results show the role of nurture in the gender gap in cognitive abilities.