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
Mexican–American War could not be released from its obligations. The US was released from all obligations of Article XI five years later by Article II of the Gadsden Purchase of 1853. The 1848 Treaty of Guadalupe Hidalgo ended the war and enforced the Mexican Cession of the northern territories of Alta California and Santa Fe de Nuevo México to the United States. Mexico acknowledged the loss of what became the State of Texas and accepted the Rio Grande as its northern border with the U.S. The losses amounted to one-third of its original territory from its 1821 independence. Before the secession of