In Peru, students attending rural schools demonstrate extremely poor learning outcomes and obtain results significantly below those of students in urban schools. Because the process of cognitive skill formation is cumulative, differences in initial endowments, early environments and influences occurring later at home and at school can all play a role in shaping these gaps. This analysis aims at measuring the contribution of school and early childhood influences to the difference in cognitive development observed, at the age of 8, between urban and rural children in Peru. Previous decomposition exercises using Peruvian data on the indigenous–non-indigenous achievement gap, report results that favour the role of household characteristics over that of schools or community-level variables. This analysis contributes new evidence based on an unusually rich dataset and provided by a decomposition strategy less prone to biases than those used so far in the literature. Results indicate that between 35 and 40 per cent of the gap in cognitive skill between urban and rural 8-year-old children is related to differences in school inputs (years of schooling, school and teacher characteristics) received between the ages of 6 and 8. This contribution is similar to that of the learning and care environment to which the child was exposed up until the age of 5. The characteristics of rural schools have a direct connection with policy action because nearly all the supply of educational services in rural areas is public. Thus, efforts devoted to ensuring the characteristics of rural schools and teachers become more equal with those in urban areas should allow a significant reduction in the cognitive skill gap between urban and rural children by the time they reach Grade 3.