<P> The Aztec capital of Tenochtitlan became the Spanish capital Mexico City, which was and remains the most populous city in Mexico . </P> <P> From 1521, the Spanish conquest of the Aztec empire incorporated the region into the Spanish Empire, with New Spain its colonial era name and Mexico City the center of colonial rule . It was built on the ruins of the Aztec capital of Tenochtitlan and became the capital of New Spain . During the colonial era, Mexico's long - established Mesoamerican civilizations mixed with European culture . Perhaps nothing better represents this hybrid background than Mexico's languages: the country is both the most populous Spanish - speaking country in the world and home to the largest number of Native American language speakers in North America . For three centuries Mexico was part of the Spanish Empire, whose legacy is a country with a Spanish - speaking, Catholic and largely Western culture . </P> <P> After a protracted struggle (1810--21) for independence, New Spain became the sovereign nation of Mexico, with the signing of the Treaty of Córdoba . A brief period of monarchy (1821--23), called the First Mexican Empire, was followed by the founding of the Republic of Mexico, established under a federal constitution in 1824 . Legal racial categories were eliminated, abolishing the system of castas . Slavery was not abolished at independence in 1821 or with the constitution in 1824, but was eliminated in 1829 . Mexico continues to be constituted as a federated republic, under the Mexican Constitution of 1917 . </P> <P> The Age of Santa Anna is the period of the late 1820s to the early 1850s that was dominated by criollo military - man - turned - president Antonio López de Santa Anna . In 1846, the Mexican--American War was provoked by the United States, ending two years later with Mexico ceding almost half of its territory via the Treaty of Guadalupe Hidalgo to the United States . Even though Santa Anna bore significant responsibility for the disastrous defeat, he returned to office . </P>

How long has mexico had a federal republic
find me the text answering this question