Why do children’s memories often differ from adults’ after the same experience? Whereas prior work has focused on immature memory mechanisms to answer this question, here we focus on the costs of attentional lapses for learning. We track sustained attention and memory formation across time in 7- to 10-year-old children and adults (n = 120) to show that sustained attention causally shapes the fate of children’s individual memories. Moreover, children’s attention lapsed twice as frequently as adults’, and attention fluctuated with memory formation more closely in children than adults. In addition, although attentional lapses impaired memory for expected events in both childre and adults, they impaired memory for unexpected events in children only. Our work reveals that sustained attention is an important cognitive factor that controls access to children’s long-term memory stores. Our work also raises the possibility that developmental differences in cognitive performance stem from developmental shifts in the ability to sustain attention.