  The science of cities seeks to understand and explain regularities observed
in the world's major urban systems. Modelling the population evolution of
cities is at the core of this science and of all urban studies. Quantitatively,
the most fundamental problem is to understand the hierarchical organization of
cities and the statistical occurrence of megacities, first thought to be
described by a universal law due to Zipf, but whose validity has been
challenged by recent empirical studies. A theoretical model must also be able
to explain the relatively frequent rises and falls of cities and civilizations,
and despite many attempts these fundamental questions have not been
satisfactorily answered yet. Here we fill this gap by introducing a new kind of
stochastic equation for modelling population growth in cities, which we
construct from an empirical analysis of recent datasets (for Canada, France, UK
and USA) that reveals how rare but large interurban migratory shocks dominate
city growth. This equation predicts a complex shape for the city distribution
and shows that Zipf's law does not hold in general due to finite-time effects,
implying a more complex organization of cities. It also predicts the existence
of multiple temporal variations in the city hierarchy, in agreement with
observations. Our result underlines the importance of rare events in the
evolution of complex systems and at a more practical level in urban planning.
