Measles epidemics in West Africa cause a significant proportion of vaccine-preventable childhood mortality. Epidemics are strongly seasonal, but the drivers of these fluctuations are poorly understood, which limits the predictability of outbreaks and the dynamic response to immunization. We show that measles seasonality can be explained by spatiotemporal changes in population density, which we measure by quantifying anthropogenic light from satellite imagery. We find that measles transmission and population density are highly correlated for three cities in Niger. With dynamic epidemic models, we demonstrate that measures of population density are essential for predicting epidemic progression at the city level and improving intervention strategies. In addition to epidemiological applications, the ability to measure fine-scale changes in population density has implications for public health, crisis management, and economic development.