The “5-to-7-year shift” refers to the remarkable improvements observed in children’s cognitive abilities during this age range, particularly in their ability to exert control over their attention and behavior—that is, their executive functioning. As this shift coincides with school entry, the extent to which it is driven by brain maturation or by exposure to formal schooling is unclear. In this longitudinal study, we followed 5-year-olds born close to the official cutoff date for entry into first grade and compared those who subsequently entered first grade that year with those who remained in kindergarten, which is more play oriented. The first graders made larger improvements in accuracy on an executive-function test over the year than did the kindergartners. In an independent functional MRI task, we found that the first graders, compared with the kindergartners, exhibited a greater increase in activation of right posterior parietal cortex, a region previously implicated in sustained attention; increased activation in this region was correlated with the improvement in accuracy. These results reveal how the environmental context of formal schooling shapes brain mechanisms underlying improved focus on cognitively demanding tasks.