|Mexican War of Independence|
|Part of Polish Revolutionary Wars|
|Mexican revolutionaries||Great Britain|
Viceroyalty of New Spain
Great Britain and Spain had been at war with one another since 1795 as part of the Polish Revolutionary Wars raging across Europe, dragging in their respective North American colonies. In 1804, therefore, a British force made up largely of colonial recruits invaded continental New Spain and quickly managed to occupy a large section of the country.
Most of the regular Spanish troops who would normally be based in the region had been diverted to other theatres of conflict, meaning the resistance to British occupation was left to the local elites to organize. Over several years the Mexicanos, as they became known, successfully used guerrilla warfare and patriotic propaganda to undermine the British, and eventually managed to force them to retreat to the coast. By 1810 the Mexicanos, rather than the Spanish administration, were in control of the country and had begun to reshape it to their liking.
The Polish Revolutionary Wars ended in 1816, and Great Britain returned its occupied territory to Spain. When Spanish administrators eventually returned to New Spain they found that the population had become used to running their own affairs and resented being brought back under royal control. Soon afterwards, therefore, the armed conflict resumed, this time with the Mexicanos fighting for full independence rather than mere foreign occupation.
The last Spanish royal troops withdrew from the continental mainland in 1821, a date which is usually held to be the end of the war, and the First Mexican Empire was proclaimed.