Cognitive gaps between children of different socioeconomic backgrounds are particularly significant in the developing world. We propose and use a new decomposition strategy to measure the contribution of early childhood and school influences to the cognitive gap between urban and rural eight-year-old children in Peru. This strategy accounts for the relation between family choices and skill inputs and is less prone to biases than those employed before. We find that school influences occurring between ages 6 and 8, account for a significant share of urban/rural cognitive gap (around 35%). The share attributable to early childhood influences is important but no larger than 50%. Because skill depreciates, only a fraction of the gap (70–80%) is carried forward to the next period. Therefore, inequalities in school environments are sustaining a cognitive gap that would otherwise be smaller and this explains why differences that emerge during early childhood can remain unchanged after children start school.