Mexico gained independence from Spain. The colony won separation through an 11-year insurgency, from Miguel Hidalgo's 1810 uprising to the 1821 entry of the Army of the Three Guarantees into Mexico City. There was no single surrender document. A royalist officer, Agustín de Iturbide, switched sides and negotiated the break with the last viceroy, Juan O'Donojú.

The answer is that simple, but the mechanism is not. Spain did not lose Mexico on a battlefield. It lost Mexico at a negotiating table, while its own liberal revolution in 1820 terrified the Mexican elite far more than independence did.

From Grievance to Insurgency: How the War Began

The trigger was a coup from above, not a peasant revolt. In 1808, Napoleon forced the abdication of Ferdinand VII and installed his brother Joseph on the Spanish throne. Legitimacy collapsed across the Spanish world. In New Spain, the peninsula-born elite (peninsulares) deposed the viceroy and ruled in the king's name, which convinced American-born Spaniards (criollos) that the colony's wealth would never be theirs.

Hidalgo, a parish priest in Dolores, launched the rising at dawn on September 16, 1810. A crowd of perhaps 600 grew into an army that reached tens of thousands within weeks. It seized the key cities of Guanajuato and Guadalajara by January 1811 but unraveled at the Bridge of Calderón.

The mechanics of why insurgency failed early matter. Hidalgo's coalition of miners, farmhands, and provincial militia lacked training, artillery, and supply lines. Royalist troops were professional, better armed, and backed by silver from Zacatecas and Guanajuato. After Hidalgo was captured and executed in 1811, leadership passed to another priest, José María Morelos, who fought a disciplined guerrilla war from Oaxaca and Michoacán until his own capture and execution in 1815.

After Morelos, the insurgency fragmented into scattered bands. Royalist forces under the viceroy's command held the cities for nearly a decade. But rural Mexico never fully pacified, and the crown's fiscal drain mounted.

Quantified Context: The Cost of Holding a Colony

Spain's hold on New Spain cost blood and treasure on a scale that made the 1821 settlement rational. Morelos's campaigns alone involved thousands of troops and militia on both sides; independent estimates of total war deaths in the 1810-1821 period run into the hundreds of thousands when battle deaths, disease, and famine in disrupted regions are combined.

Silver was the real ledger. New Spain produced the bulk of Spain's colonial silver, and the insurgency disrupted mining and transport routes for over a decade. Tax remittances to Madrid fell, while the cost of garrisoning the colony rose. Mexico's measured silver output in the late colonial decades has been estimated in the range of roughly 20 million pesos annually by economic historians, a figure that contracted sharply during the war years.

Spain's own crisis compounded the arithmetic. The Peninsular War (1808-1814) against Napoleon devastated the Spanish army and treasury. When Ferdinand VII returned in 1814 and repudiated the liberal Constitution of 1812, he alienated the very criollo royalists who had defended Spanish rule. The American insurgency and the Spanish fiscal collapse reinforced each other.

Edge Cases: Why "Spain" Needs Qualifying

A careful answer names which Spain. Until 1820, the crown, the viceroy, and the royalist army defended Bourbon absolutism. After January 1820, a liberal military revolt in Spain (the Riego uprising) forced Ferdinand to restore a constitutional monarchy. That same liberal constitution threatened the Church's privileges and the army's corporate courts in Mexico.

So the counterintuitive detail: most of the men who made independence possible in 1821 were conservative royalists. Iturbide had spent a decade fighting insurgents. He switched sides because he feared a liberal Spain would dismantle the Catholic hierarchy and elite privileges more than he feared an independent Mexico.

A second edge case is the papel sellado—the stamped-paper tax and bureaucracy that made Spanish rule tangible in everyday commerce. Independence promised to remove it. Tiny administrative grievances amplified elite support.

Frontier regions: Texas and California remained lightly settled and royalist until late; their fate was settled by the 1821 declaration and later. Guatemala and Central America declared independence in September 1821, largely as a cascade from Mexico's break. The Treaty of Córdoba (August 24, 1821) made Mexico a constitutional monarchy under a European prince; no Bourbon prince ever accepted the crown. Iturbide's 1822 self-coronation as emperor collapsed within months, and a republic was declared in 1824. Spain did not recognize Mexican independence until 1836, after Ferdinand's death.

Misconceptions: What Independence Was Not

First misconception: independence was a popular democratic revolution. It was a negotiated transfer that preserved the social hierarchy, the Church's wealth, and the officer corps. Hidalgo's execution orders and Morelos's executed republicanism are often romanticized, but the men who signed the break in 1821 were the war's counterrevolutionaries.

Second misconception: the independence date is September 16. That is the anniversary of Hidalgo's 1810 uprising, celebrated as the Grito de Dolores. Independence was legally consummated on September 27, 1821, when Iturbide's army entered Mexico City and the new government was proclaimed.

Third misconception: the Treaty of Córdoba settled everything. It was signed by Viceroy O'Donojú, who had just arrived and had no authority to concede; the Spanish government later repudiated it. A separate Mexican act of independence was drawn up in September 1821 by a junta in Mexico City.

Fourth misconception: Spain gave up because it was defeated militarily in Mexico. Spain's defeat came in the Spanish Revolution and fiscal bankruptcy at home. The colony was lost in the negotiation, not the field.

Question Short answer Key date Source of authority
Who did Mexico gain independence from? Spain, specifically the Bourbon crown and viceregal government Sept 16, 1810 to Sept 27, 1821 Treaty of Córdoba; act of independence
Was it a war or negotiation? Both: long insurgency, then negotiated settlement Aug 24, 1821 Iturbide and O'Donojú's treaty
Did Spain recognize it? No, not until 1836 1836 Spanish recognition
What ended Spain's claim? Loss of military control plus domestic liberal revolution 1820-1821 Riego uprising; constitutional crisis in Spain
What was the independence date? September 27, 1821 (September 16 is the uprising anniversary) 1821 Army of the Three Guarantees entry
Who signed for Spain? Viceroy Juan O'Donojú, whose authority was later repudiated 1821 Treaty of Córdoba
Date Event Why it mattered
1808 Napoleon forces Ferdinand VII to abdicate Collapses royal legitimacy in New Spain
Sept 16, 1810 Hidalgo's Grito de Dolores Opens the insurgency; 11 years of war follow
1815 Morelos executed Insurgency fragments into regional bands
Jan 1, 1820 Riego revolt restores Spain's liberal constitution Alarms Mexican Church and army elites
Feb 24, 1821 Plan de Iguala Iturbide's three guarantees: religion, independence, equality
Aug 24, 1821 Treaty of Córdoba signed Names Mexico a monarchy under a European prince
Sept 27, 1821 Army of the Three Guarantees enters Mexico City Independence proclaimed; Spanish rule ends
1836 Spain formally recognizes Mexican independence Settles the legal question a generation later

Practical Actions: How to Verify the Question Yourself

If you are checking this for a class, a quiz, or a citation, build the answer in three steps.

Start with the legal instrument: the Treaty of Córdoba (August 24, 1821). Read the Spanish and Mexican texts, not summaries. A threshold rule: if a source dates independence to September 16, it is describing the 1810 uprising, not the 1821 settlement. If it dates independence to 1810, treat it as shorthand for the war's start and flag it.

Then check the date of the entering army: September 27, 1821, according to the Mexican act of independence. Then check the recognition date: Spain did not recognize Mexico until 1836.

For contested claims—for example, whether Iturbide was a traitor or a founder—use primary sources: Iturbide's Plan de Iguala (February 24, 1821) lays out the three guarantees of religion, independence, and equality. O'Donojú's correspondence shows a viceroy improvising under instructions to avoid bloodshed.

Red flag: a source that calls independence "granted" by Spain. Spain repudiated the treaty. Red flag: maps that treat Texas and California as Mexican from 1821 without noting sparse settlement and later separation. Red flag: casualty figures with no stated method; war-period death estimates are uncertain. Red flag: treating September 16 as the independence date in a formal citation. It is the holiday, not the date. Red flag: assuming independence ended social inequality. It did not.

Limits: What the Record Cannot Settle

Precise casualty numbers for 1810-1821 do not exist. Parish registers were destroyed or interrupted, and combatants and civilians were not counted separately. Historians offer ranges, not audited totals. Silver output figures are estimates from tax and mint records, and the series are incomplete for the war years. The rate at which tax remittances fell cannot be pinned down with single-digit precision.

The documentary record is also one-sided. The viceregal papers, the insurgent correspondence, and the later national accounts each serve different interests. O'Donojú's instructions and authority remain legally ambiguous: he signed what he could not lawfully concede, and the Spanish government said so.

There is a deeper limit. The question "who did Mexico gain independence from" assumes a single sovereign counterparty. In 1821, sovereignty itself was contested in Spain between the crown and the liberal Cortes. Mexico's break was fired as much by that Spanish internal fracture as by the insurgency. A clean answer is still Spain, but the mechanism is a double dissolution, and no source resolves how much each cause contributed.