As early as 10,000 BC, people and animals lived around Lago de Texcoco, the lake that then covered much of the floor of the Valle de México. After 7500 BC the lake began to shrink, hunting became more difficult, and the inhabitants turned to agriculture. A federation of villages evolved around the lake by 200 BC, but the biggest one, Cuicuilco, was destroyed by a volcanic eruption that occurred around AD 100.
The next major influence in the area was Teotihuacán, 25km (16mi) northeast of the lake. For centuries Teotihuacán was the capital of an empire stretching to Guatemala and beyond, but it fell in the 7th century. Of several city-states in the region in the following centuries, the Toltec empire, based at Tula, 65km (40mi) north of modern Mexico City, was the most important. By the 13th century the Tula empire had fallen too, leaving a number of small statelets around the lake to spat over the Valle de México. The Aztecs emerged as the winners.
Wrecked during and after the Spanish conquest, the Aztec capital Tenochtitlán was rebuilt as a Spanish city. The native population of the Valle de México shrank drastically - to fewer than 100,000 within a century of the conquest, by some estimates. But the city itself emerged by 1550 as the prosperous and elegant, if insanitary, capital of Nueva España. Broad, straight streets were laid out and buildings constructed to Spanish designs with local materials such as tezontle, a light-red volcanic rock that the Aztecs had used for their temples. Hospitals, schools, churches, palaces, parks and a university were built. But right up to the late 19th century the city suffered floods caused by the partial destruction in the 1520s of the Aztecs' canals. Lago de Texcoco often overflowed into the city, damaging buildings, bringing disease and forcing thousands of people away from their homes.
On October 30, 1810, some 80,000 independence rebels had Mexico city at their mercy after defeating Spanish loyalist forces at Las Cruces, just west of the capital. But leader Miguel Hidalgo decided against advancing on the city - a mistake that cost Mexico 11 more years of fighting before independence was achieved.