Mexico gained independence from Spain in 1821. The decisive end of Spanish rule came when the Army of the Three Guarantees entered Mexico City on September 27, 1821, followed by the declaration of independence the next day.
The independence movement had begun much earlier. On September 16, 1810, the priest Miguel Hidalgo y Costilla issued the Grito de Dolores, calling for revolt against colonial rule. That uprising began the Mexican War of Independence, but it did not immediately create an independent country. Hidalgo was captured and executed in 1811, and later leaders, including José María Morelos, continued the struggle.
The final stage took shape in 1821, when former royalist commander Agustín de Iturbide joined forces with insurgent leader Vicente Guerrero. Their Plan of Iguala called for independence, religious unity, and equality among groups in New Spain. The Treaty of Córdoba followed in August, and the independence declaration was issued in September.
The date 1810 is therefore the start of the independence war, while 1821 is the year Mexico achieved independence. Spain formally recognized Mexican independence only in 1836.