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.
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.
After the French occupation in Spain, the City Council of Mexico declared itself sympathetic to the creation of a sovereign Junta to govern New Spain for the duration of the occupation. The most radical members, such as Francisco Primo de Verdad and Melchor de Talamantes, thought that independence should be final. The Junta of Mexico had the support of Viceroy José de Iturrigaray. However, a reactionary movement imprisoned the members of the city council on September 15, 1808 and obtained the removal of the viceroy.
After the start of the independence revolution in Dolores, Guanajuato, the objective of the insurgent troops was the capture of the capital. Their paths led them to the outskirts of Mexico City. Hidalgo and his army arrived in Cuajimalpa shortly after proclaiming independence in Dolores. They defeated the royalists in the battle of Monte de las Cruces, and despite this, the insurgents decided to return to the Bajío without taking the capital.
From then on, the Valley of Mexico was no longer a military objective of the independentistas, and had become the stronghold of the royalist army. Towards 1820, when the popular revolution was almost extinct, Mexico City was the seat of new movements against the viceregal government. This time, the conspirators were the same ones who had achieved the removal of Iturrigaray, who after the approval of the Constitution of Cádiz saw their privileges threatened. Among them was Agustín de Iturbide, who sealed a pact (Plan de Iguala) with Vicente Guerrero (head of the revolution in southern Mexico) and later forced Juan O’Donojú to sign the Treaties of Córdoba that declare the independence of Mexico.. The Trigarante Army triumphantly entered Mexico City on September 27, 1821, after Agustín Iturbide is proclaimed emperor of the Mexican Empire, by the congress, crowning himself in the Cathedral of Mexico.
19th and 20th centuries
After independence, Mexico City was the capital of the state of the same name. On November 18, 1824, Congress decided to create a federal district, an entity that would house the federal powers. The territory of the Federal District was made up of Mexico City and six other municipalities: Tacuba, Tacubaya, Azcapotzalco, Mixcoac and Villa de Guadalupe-Hidalgo. On February 20, 1837, the Federal District was suppressed, to be reestablished in 1846.
During the 19th century, the Federal District was the central scene of all the political disputes in the country. It was the imperial capital on two occasions (1821-1823 and 1864-1867), and of two federalist states and two centralist states that succeeded each other after countless coups d’état in the space of half a century before the triumph of the liberals after the War of the Reform.. It was also the target of one of the two French invasions of Mexico (1861-1867), and occupied for a year by American troops in the framework of the American Intervention War (1847-1848).
Towards the end of the 19th century, the Government of Mexico decided to carry out numerous urban works that, although they had Mexico City as their focus, would end up affecting the entire territory of the Federal District. Among them is the construction of the Grand Canal del Desagüe, begun around 1878 and completed in 1910. This work brought the lakes that covered a large part of the capital’s territory almost to the brink of extinction. Steamboats were introduced for transportation through the canals of the valley, and trams for land transportation. Little is said about culture in this century, which had among its most notable characters José María Velasco, naturalist and landscape painter from the Valley of Mexico. At this time, musical genres such as son and syrup became popular in the capital. And in the field of literature, works such as El periquillo sarniento, by José Joaquín Fernández de Lizardi were written.
In operatic production, Aniceto Ortega’s opera Guatemotzín is the first conscious attempt to incorporate native elements into the formal characteristics of the opera. Within the Mexican operatic production of the 19th century, the opera Agorante, rey de la Nubia by Miguel Meneses, premiered during the commemorative festivities for the birthday of Emperor Maximiliano I of Mexico, the operas Pirro de Aragón by Leonardo Canales, Keofar by Felipe Villanueva stand out., and, above all, the operatic production of Melesio Morales, the most important Mexican composer of operas of the 19th century, whose works were very successful among the public in Mexico City and which, still, were released in Europe.
With the beginning in the 20th century of the Mexican Revolution (which ended decades of Porfirio Díaz’s dictatorship), the Federal District was successively occupied by the Maderistas, the Zapatistas and Villistas, and finally the Carrancistas. This last faction would be replaced by the so-called Grupo Sonora, which in turn would give rise to the Institutional Revolutionary Party (and its antecedents) that dominated the Government of Mexico from 1929 to 2000.
In 1929 the municipal system in the Federal District was abolished, with which the thirteen existing municipalities in its territory disappeared. Later a law would be promulgated that divided the entity into sixteen political delegations whose residents were unable to elect representatives and local governments until 2000. With the period of economic peak known as the Mexican Miracle (1950s and 1960s), Mexico City He lived through a period of unprecedented urbanization in the country. Its population doubled in less than twenty years, and it gradually absorbed the nearby towns, until it overflowed the territory of the Federal District. Numerous public works were inaugurated in that period. Among them we can mention the Ciudad Universitaria and the Azteca Stadium.
Also from 1950, Mexico City was the scene of numerous expressions of disagreement against the PRI government. In the 1950s, the railroad protests took place, which ended with the imprisonment of several of their leaders (such as Demetrio Vallejo). In 1968, students from numerous public and private schools also started a series of protests that ended with the Tlatelolco Massacre on October 2 by the Mexican Army. Three years later, on June 10, 1971, a demonstration of students from the Higher Normal School were attacked by the Government, in what is known as Corpus Thursday. On September 19 In 1985, Mexico City was severely damaged by an 8.1 Richter earthquake. From then on, the capital’s civil society began to increasingly take control of those spaces that the State had left abandoned. As a result, in the controversial federal elections of 1988, the PRI was widely defeated in the Federal District by the FDN.
In 1997, the Federal District elected its head of government for the first time since 1929. On that occasion, the PRI lost control of the city at the hands of the Party of the Democratic Revolution (PRD) and its candidate Cuauhtémoc Cárdenas Solórzano. Since then, this party has won the elections for the head of the Federal District government on three consecutive occasions (1997, 2000, 2006).
Mexico City in the 21st century
The politician Andrés Manuel López Obrador, who was head of the Federal District Government from 2000 to 2005, is one of the most popular politicians in the city.
The last federal election in Mexico (2006) had as an official result the victory of Marcelo Ebrard in the election for Head of Government of the Federal District, as well as a closed difference between the PRD candidates (Andrés Manuel López Obrador) ―who had been chief of the Federal District Government from 2000 to 2005 – and of the PAN (Felipe Calderón), the final count being favorable to the latter. After July 2, the Federal District was the scene of demonstrations calling for a full recount of the election. The total recount was denied by the electoral authorities, who only authorized the opening of a smaller percentage of the electoral packages. As a pressure mechanism, López Obrador supporters installed a 40-day sit-in in the Plaza de la Constitución, Avenida Juárez and Paseo de la Reforma that lasted until September 15 and was set up a few hours before the traditional military parade that it runs through the same streets and avenues where the sit-in was installed. The PRD occupation of the Zócalo and one of the capital’s most important arteries kept opinions divided in the capital.
The Federal District became, in 2006, the first federal entity in Mexico to legally recognize unions between people of the same sex. This happened through the approval of the Law of Coexistence Societies on November 9 of that year in the Legislative Assembly of the capital; on December 21, 2009 it also recognized same-sex marriage  , becoming the first Latin American city to approve it. In April 2007 it also became the first federal entity to decriminalize abortion before 12 weeks of pregnancy. The law was criticized by the Catholic hierarchy and conservative organizations.
Another health event took place in the City, when on the night of April 23, 2009, the Federal Government announced the start of the AH1N1 flu outbreak. This led to the initiation of a prevention campaign with the citizens of the capital and the people of Mexico; For this reason, work was suspended in most of the activities of the city and metropolitan area, from April 24 to May 7. Thanks to that, the virus that started an epidemic was controlled.