The military history of Mexico encompasses armed conflicts within that nation's territory, dating from before the arrival of Europeans in 1519 to the present era. Mexican military history is replete with small-scale revolts, foreign invasions, civil wars, indigenous uprisings, and coups d'état by disgruntled military leaders. Mexico's colonial-era military was not established until the eighteenth century. After the Spanish conquest of the Aztec Empire in the early sixteenth century, the Spanish crown did not establish on a standing military, but the crown responded to the external threat of a British invasion by creating a standing military for the first time following the Seven Years' War (1756–63). The regular army units and militias had a short history when in the early 19th century, the unstable situation in Spain with the Napoleonic invasion gave rise to an insurgency for independence, propelled by militarily untrained men fighting for the independence of Mexico. The Mexican War of Independence (1810–21) saw royalist and insurgent armies battling to a stalemate in 1820. That stalemate ended with the royalist military officer turned insurgent, Agustín de Iturbide persuading the guerrilla leader of the insurgency, Vicente Guerrero, to join in a unified movement for independence, forming the Army of the Three Guarantees.Archer, Christon I. “Military: Bourbon New Spain” in Encyclopedia of Mexico, 898–904 The royalist military had to decide whether to support newly independent Mexico. With the collapse of the Spanish state and the establishment of first a monarchy under Iturbide and then a republic, the state was a weak institution. The Roman Catholic Church and the military weathered independence better. Military men dominated Mexico's nineteenth-century history, most particularly General Antonio López de Santa Anna, under whom the Mexican military were defeated by Texas insurgents for independence in 1836 and then the U.S. invasion of Mexico (1846–48). With the overthrow of Santa Anna in 1855 and the installation of a government of political liberals, Mexico briefly had civilian heads of state. The Liberal Reforms that were instituted by Benito Juárez sought to curtail the power of the military and the church and wrote a new constitution in 1857 enshrining these principles. Conservatives comprised large landowners, the Catholic Church, and most of the regular army revolted against the Liberals, fighting a civil war. The Conservative military lost on the battlefield. But Conservatives sought another solution, supporting the French intervention in Mexico (1862–65). The Mexican army loyal to the liberal republic were unable to stop the French army's invasion, briefly halting it with a victory at Puebla on 5 May 1862. Mexican Conservatives supported the installation of Maximilian Hapsburg as Emperor of Mexico, propped up by the French and Mexican armies. With the military aid of the U.S. flowing to the republican government in exile of Juárez, the French withdrew its military supporting the monarchy and Maximilian was caught and executed. The Mexican army that emerged in the wake of the French Intervention was young and battle tested, not part of the military tradition dating to the colonial and early independence eras.

Liberal General Porfirio Díaz was part of the new Mexican military, a hero of the Mexican victory over the French on Cinco de Mayo 1862. He revolted against the civilian liberal government in 1876, and remained continuously in the presidency from 1880 to 1911 (Porfiriato). Over the course of his presidency, Díaz began professionalizing the army that had emerged. By the time he turned 80 years old in 1910, the Mexican military was an aging, largely ineffective fighting force. When revolts broke out in 1910–11 against his regime, a rebel forces scored decisive victories over the Federal Army in the opening chapter of the Mexican Revolution (1910–1920). Díaz resigned in May 1911, but Francisco I. Madero, on whose political behalf rebels rose against Díaz, demobilized the rebel forces and kept the Federal Army in place. "This single decision cost [Madero] the presidency and his life."Krauze, Enrique, Mexico: Biography of Power. New York: HarperCollins 1997, p. 510. Army General Victoriano Huerta seized the presidency of Madero in 1913, with Madero murdered in the coup d'état. Civil war broke out in the wake of the coup. Huerta's Federal Army racked up one defeat after another by the revolutionary armies, with Huerta resigning in 1914. The Federal Army ceased to exist.Archer, Christon I. “Military: 1821–1914” in Encyclopedia of Mexico, 904–910 A new generation of fighting men, most of whom with no formal military training, now fought against each other in a civil war of the winners. The Constitutionalist Army under the civilian leadership of Venustiano Carranza and the military leadership of General Álvaro Obregón were the victors in 1915. The revolutionary military men were to continue to dominate Mexico's postrevolutionary period, but the military men who became presidents of Mexico brought the military under civilian control, systematically reining in the power of the military and professionalizing the force. The Mexican military has been under civilian government control with no President of Mexico being military generals since 1946.Serrano, Mónica. "Military: 1914–1996" in Encyclopedia of Mexico, 911 The fact of Mexico's civilian control of the military is in contrast the situation in many other countries in Latin America.Krauze, Mexico: Biography of Power, p. 510.

Mexico stood among the Allies of World War II and was one of two Latin American nations to send combat troops to serve in the Second World War. Recent developments in the Mexican military include their suppression of the 1994 Zapatista Army of National Liberation in Chiapas, control of narcotrafficking, and border security.

Pre-Hispanic era, before 1519

Before the arrival of Europeans in 1492, there were many large-scale civilizations in Mesoamerica that had engaged in conquest of rival powers. As civilizations arose, traditional raiding to plunder resources evolved into full-scale conquests between 300 BCE and 150 BCE, with occupying forces that could direct tribute from the conquered to the conquerors. Conquest on a grand scale only occurred with the Aztec Empire, which coalesced in the fifteenth century C.E., but smaller-scale conquests affected the rise and fall of civilizations before that.Marcus, Joyce. "Conquests: Pre-Hispanic Period" in The Oxford Encyclopedia of Mesoamerican Cultures, ed. David Carrasco. New York: Oxford University Press, 2001, vol. 1, pp. 251–254. As early as Teotihuacan and Monte Albán, the first Mesoamerican states, there is evidence of local conquests of defensive walls around urban cores and conflicts resulting in large-scale sacrifice of warriors. There were cycles of conquests over many hundreds of years, resulting in the rise and decline of civilizations.Marcus, "Conquests: Pre-Hispanic Period", p. 252.

For many years, scholars depicted the Maya as peaceful, but there is ample evidence of Maya warfare in glyphic written texts and pictorials, as well as archeological evidence of "fortifications, mass graves, and militaristic iconography," indicating warfare's importance.Marcus: "Conquests: Pre-Hispanic Period", p. 252. In the 6th century, a series of wars between the Tikal and Calakmul erupted on the Yucatán. The Mayan conflict also included vassal states in the Petén Basin such as Copan, Dos Pilas, Naranjo, Sacul, Quiriguá, and briefly Yaxchilan had a role in initiating the first war. There is also evidence of conquests in the region of the Mixtecs, Zapotecs, and Purépecha (or Tarascans), which were not as extensive as the Aztec empire, but followed the same pattern on a smaller scale.Marcus, Joyce. "Conquests: Pre-Hispanic Period", pp. 252–53.

Prior to Spanish colonization, in the 15th century, several wars ensued between the Aztecs and several other native tribes. Alliances between the Aztec state and Texcoco had become central to these pre colonial wars. Several of these conflicts were evolved to an organized warfare, known as the Flower wars. In the Flower wars the primary objective was to injure or capture the enemy, rather than killing as in Western warfare. Prisoners-of-war were ritually sacrificed to Aztec gods. Cannibalism was also a center feature to this type of warfare. Historical accounts such as that of Juan Bautista de Pomar state that small pieces of meat were offered as gifts to important people in exchange for presents and slaves, but it was rarely eaten, since they considered it had no value; instead it was replaced by turkey, or just thrown away.

Perhaps the most famous of the Native Mexican states is the Aztec Empire. In the 13th and 14th centuries, around Lake Texcoco in the Anahuac Valley, the most powerful of these city states were Culhuacan to the south, and Azcapotzalco to the west. Between them, they controlled the whole Lake Texcoco area.

The Aztecs hired themselves out as mercenaries in wars between the Nahuas, breaking the balance of power between city states. Tenochtitlan, Texcoco, and Tlacopan formed a "Triple Alliance" that came to dominate the Valley of Mexico, and then extended its power beyond. Tenochtitlan, the traditional capital of the Aztec Empire, gradually became the dominant power in the alliance.

The Chichimeca, a wide range of nomadic groups that inhabited the north of modern-day Mexico, were never conquered by the Aztecs.

Spanish conquest of Mexico

The two-year Spanish conquest of the Aztec Empire (1519–1521) is the most famous episode of Spanish conquest history. It is documented in the sixteenth century by both Spaniards, their indigenous allies, and indigenous opponents shortly after the events.Altman, Ida, et al. The Early History of Greater Mexico. Prentice Hall 2003, p. 53, pp. 73–96 With arrival of Spaniards in the Caribbean in 1492, they developed patterns of conquest and settlement. From the Caribbean, they went on expeditions (entradas) of exploration, trade, conquest, and settlement. The Spanish crown issued a license for a particular leader to head an expedition, a mature man with wealth, social standing, and ambition to better his position. Explorers probed Mexico's east coast, with Francisco Hernández de Córdoba exploring southeast Mexico in 1517, followed by Juan de Grijalva in 1518. The most important Conquistadores was Hernán Cortés, a settler in Cuba who was well-connected locally. He received a license to lead an expedition of exploration only. As was standard practice for an expedition, those joining it brought their own weapons and armor, and if wealthy enough, a horse. If an entrada of conquest was successful, participants would receive shares of the spoils, with each man receiving one share, and if he was a horseman, an additional share. These expeditions were not organized armies of salaried troops funded by the crown, but groups of settlers turned bands of men in combat or soldiers of fortune, who joined with the expectation that their valor and skill in combat would be rewarded. The term "soldier" was not used by participants themselves. The leader was often called "captain", but this was not a military rank.Lockhart, James and Stuart B. Schwartz, Early Latin America. Cambridge: Cambridge University Press 1982, pp. 79–80 Cortés did not want to be restricted by the license limiting him solely to exploration of Mexico's coast, and left Cuba before officials realized his ambition. For that reason, once the Spanish would-be conquerors landed on the mainland, they needed to find way to constitute themselves as a legal entity. They did so by founding the town of Villa Rica de la Vera Cruz (today's Veracruz), and constituting themselves as the city council. They chose Hernán Cortés as their captain.