Mexico Europeans. In 1521, the Spanish Empire conquered and colonized the territory from its politically powerful base in Mexico-Tenochtitlan (part of Mexico City), which was administered as the viceroyalty of New Spain. Three centuries later, the territory became a nation state following its recognition in 1821 after the colony's Mexican War of Independence. The post-independence period was tumultuous, characterized by economic inequality and many contrasting political changes. The Mexican–American War (1846–1848) led to a territorial cession of the extant northern territories to the United States. The Pastry War, the Franco-Mexican War, a civil war, two empires, and the Porfiriato occurred in
Latin American wars of independence movement against their colonial master, finally ended as a full-fledged civil war. Traditionally, the process is divided into three stages: Patria Vieja, Reconquista, and Patria Nueva. The first uprising against Spanish rule took place in 1809, and criollos in Ecuador set up a junta on September 22, 1810 to rule in the name of the Bourbon monarch; but as elsewhere, it allowed assertion of their own power. Only in 1822 did Ecuador fully gain independence and became part of Gran Colombia, from which it withdrew in 1830. At the Battle of Pichincha, near present-day Quito, Ecuador on May 24, 1822,