Mexico was a Spanish colony.
The Mexican War of Independence ( [ Guerra de Independencia de México , links = no ] ) was an armed conflict , and the culmination of a political and social process which ended the rule of Spain in 1821 in the territory of New Spain . Mexico . With an estimated population of over 120 million , it is the eleventh most populous country and the most populous Spanish-speaking country in the world while being the second most populous country in Latin America . Three centuries later , this territory became Mexico following recognition in 1821 after the colony 's Mexican War of Independence .