The oldest evidence of human occupation in the territory of the Federal District come from the Woman of the Rock and San Bartolo Atepehuacán, and correspond to the Lower Cenolithic period (9500 – 7000 BC). During the first three millennia before our era, under the influence or shadow of the Olmec culture, several important populations such as Cuicuilco developed here. Towards the end of the Preclassic, the Cuicuilca hegemony yielded to the heyday of Teotihuacan, located northeast of Lake Texcoco. During the Classic this city was a nucleus that concentrated most of the residents of the lake basin, leaving Azcapotzalco as one of its satellites on the west bank, occupied by peoples of Otomian descent. In the east of the lake, the Cerro de la Estrella was the seat of a small Teotihuacan town.
Towards the 8th century the decline of Teotihuacan began. Some of its residents moved to the shores of Lake Texcoco, where they founded towns such as Culhuacán, Coyoacán and Copilco. The area was the destination of the migrations of the Teochichimecas during the 8th and 13th centuries, peoples that originated the Toltec and Mexica cultures. The latter arrived around the 14th century to settle first on the shore of the lake, and then on the islet of Mexico, where they founded their capital. Together with their allies, the Mexica dominated a territory of about 300,000 square kilometers. The flourishing of Tenochtitlan was interrupted due to the Spanish conquest.
The Spanish arrived in the territory that is currently the Federal District through Itztapalapan, in July 1519. They continued on their way along the Itztapalapan causeway to the Tenochca capital  where Hernán Cortés was received by Moctezuma Xocoyotzin on November 8, 1519. In 1520, Pedro de Alvarado (in the absence of Cortés) attacked the Mexica in the Matanza de Toxcatl. This fact was the point at which the Mexica began hostilities against the European invaders.
During the conquest Hernán Cortés had Malinche as his translator, who was the one who helps him in communicating with the Aztecs. Several legends have been created about this character. In replacement of Moctezuma – murdered by the Spanish – Cuitláhuac was elected tlatoani of Tenochtitlan. Leading the resistance against the Spanish occupation, he defeated the invaders and their indigenous allies on June 30, 1520. At that time, a disastrous smallpox epidemic also took place, claiming thousands of lives, including that of Cuitláhuac himself. As a substitute for Cuitláhuac, Cuauhtémoc was chosen. This one had to face the siege of the Spanish allied with the indigenous people of the Puebla-Tlaxcala valley. Cuauhtémoc surrendered after multiple defeats by the Mexica and Tlatelolcas, on August 13, 1521.
Since the city of Tenochtitlan had been left in a sorry state, Cortés decided to establish the Spanish Government in the town of Coyoacán, south of Lake Texcoco. From there he ruled with the title of Captain General and Senior Justice. The conquest expeditions set out from Coyoacán with the purpose of subduing the indigenous peoples of the various directions of what would become the viceroyalty of New Spain. In 1528 the First Audience of Mexico was established, headed by Nuño de Guzmán. In 1535 the viceroyalty of New Spain was created, with its first viceroy, Antonio de Mendoza.
According to Thesciencetutor.org, Mexico City was divided into neighborhoods that settled on the territorial structures of the calpullitin Mexica. The lands around the lake were divided into encomiendas, which later became town halls. The Indian villages were originally located on the shores of Spanish cities, although with the passage of time the boundaries became less and less clear and the Indians came to live in the Spanish villages, almost always for work reasons. At the same time that various political institutions were founded in the new Spanish dominions, a process of acculturation of the natives also took place. There was an intense campaign of Latinization of the Indians, led first by the Franciscans, who established institutions such as the Colegio de la Santa Cruz de Tlatelolco. In them, the indigenous nobles learned Latin, the doctrine of the Catholic Church and numerous arts and crafts.
During the colonial era, Mexico City was filled with sumptuous constructions, either for religious worship, such as buildings for the administration, or residences of the Creole and peninsular elite. In contrast, most of the population, indigenous, lived in poverty in the suburbs and the riverside or mountain villages. While the city center was the object of constant beautification (such as the remodeling of the Zócalo, or the paving of the streets, at the expense of the old canals); on the shores people lived in wattle and daub houses set on swamps.
The viceregal city was the victim of several floods (1555, 1580, 1607, 1629, 1707, 1714, 1806), the result of the destruction of the dikes that protected it during the siege of Tenochtitlan, of which the largest was that of 1629. This fact led to the decision to drain the lake system of the basin, by means of the construction of a canal and a pit, to exit the basin through the Tula river.
In the cultural aspect, it should be mentioned that in 1711 the opera La Parténope was premiered in Mexico City with music by Manuel de Sumaya, master of the cathedral chapel and the greatest Mexican baroque composer. The special importance of this opera is that it is the first composed in North America and the first opera composed on the continent by an American. This opera begins the fruitful and still little studied history of Mexican operatic creation, uninterrupted since then for three hundred years.