Understanding the rise, spread, and fall of large-scale states in the ancient world has occupied thinkers for millennia. However, no comprehensive mechanistic model based on their insights has emerged, leaving it difficult to evaluate empirically or quantitatively the different explanations offered. Here I present a spatially- and temporally-resolved agent-based model of large-scale (>200 thousand km2) agrarian states and steppe nomadic confederations in Afro-Eurasia between the middle Bronze and the end of the Medieval era (1500 BCE - 1500 CE). The model tracks the spread of agrarian states as they expand, conquer the territory of other states or are themselves conquered, depending on their relative modeled population size and military efficiency. To accurately retrodict the historical record, several key regional technological advances in state military and agricultural efficiencies are identified. Modifying the location, scale, and timing of these innovations allows quantitative investigation of historically-plausible alternative trajectories of state growth, spread, and fragmentation, while demonstrating the operation and limits of the model. In particular, under nominal assumptions, the historically rapid increase of agrarian state sizes, first in southwest Asia after 600 CE and then in east Asia after 200 BCE, is accounted for by modeling increasing military efficiency improvements in response to intense extortion pressure from nomadic tribes and subsequent ‘mirror’ confederations following the invention and slow diffusion of horse cavalry tactics across the steppe after 1000 BCE. However, in spite of various technological advances, throughout the period the modeled creation and spread of new agrarian states is a fundamental consequence of state collapse and internal civil wars triggered by rising 'demographic-structural' pressures that occur when territorial growth is checked yet (elite) population growth continues. Together the model's underlying mechanisms substantially account for the number of states, their duration, location, spread rate, overall occupied area, and population size for three millennia.