The Peninsular War was a war between France and the allied powers of Spain, the United Kingdom, and Portugal for control of the Iberian Peninsula during the Napoleonic Wars. The war began when French armies crossed Spain and invaded Portugal in 1807 and then in 1808 turned on its ally, Spain. The war lasted until the Sixth Coalition defeated Napoleon in 1814.
Spain's liberation struggle marked one of the first national wars and the emergence of large-scale guerrillas, from which the English language borrowed the word. The French occupation destroyed the Spanish administration, which fragmented into quarrelling provincial juntas. In 1810, a reconstituted national government fortified itself in Cádiz and proved unable to recruit, train, or equip effective armies due to being under siege. British and Portuguese forces secured Portugal, using it as a secure position from which to launch campaigns against the French army while Spanish guerrilleros bled the occupiers. Combined, the regular and irregular allied forces prevented Napoleon's marshals from subduing the rebellious Spanish provinces.