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
Afro-Mexicans in the Mexican War of Independence majority of them still is linked to agricultural economic activities. The war of independence was precipitated by events in Europe, specifically a failed coup against the viceroy Joseph Bonaparte. This encouraged small groups of rebels to take up arms against colonial rule. In September 1810, peasants and indigenous inhabitants of Dolores (Guanajuato) were called to action by the secular Catholic priest Miguel Hidalgo y Costilla, former rector of the Colegio de San Nicolás Obispo. People of color were able to see that their independence was worth putting up a fight for it. However, Hidalgo was defeated. José Maria Morelos y