Mexican–American War from the war of independence (1810–1821) as a weak and divided force. Before the war with the United States, the military faced both internal and foreign challenges. The Spanish still occupied the coastal fortress of San Juan de Ulúa, and Spain did not recognize Mexico's independence, so that the new nation was at risk for invasion. In 1829, the Spanish attempted to reconquer their former colony and Antonio López de Santa Anna became a national hero defending the homeland. The army had a set of privileges ("fueros"), established in the colonial era, that gave it jurisdiction over many aspects of
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,