<P> The history of Mexico, a country in the southern portion of North America, covers a period of more than three millennia . First populated more than 13,000 years ago, the territory had complex indigenous civilizations before being conquered and colonized by the Spanish in the 16th century . One of the important aspects of Mesoamerican civilizations was their development of a form of writing, so that Mexico's written history stretches back hundreds of years before the arrival of the Spaniards in 1519 . This era before the arrival of Europeans is called variously the prehispanic era or the precolumbian era . </P> <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>

When did mexico come under spanish colonial rule