In 1807 Napoleon sent an army down into Spain under Jean-Andoche Junot to invade Portugal as they refused to join the Continental System, Lisbon was captured on December 1. Napoleon Bonaparte then began sending troops into Spain; Pamplona and Barcelona were seized in February. A Spanish coup forced Charles IV from his throne and replaced him with Ferdinand VII. Napoleon removed the royals to Bayonne and forced them to abdicate (May 5), giving the throne to his brother Joseph. When Joseph tried to enforce his rule in Spain he provoked a popular uprising.
The British had been forced to hold back from military operations on mainland Europe. But with the rising in Spain the British were prepared to commit substantial forces. In August 1808 the first British forces landed in Portugal under the command of then General Sir Arthur Wellesley.
The Spanish army had won a surprising victory over the army of Pierre Dupont at Bailén (May 19-21). The British defeated forces under the command of Delaborde at Roliça on August 17. On August 21 the British were strongly engaged at Vimeiro by French forces command by Junot. For once the dynamic tactics of the French failed and the British held their line. Wellesley was replaced as commander by Harry Burrard and Hew Dalrymple. The British victories led to the French withdrawing from Portugal under the controversial Convention of Sintra. The British commanders were ordered back to England for the inquiry into Sintra leaving Sir John Moore to head the 30,000 strong British force.
The British and Spanish victories combined to provoke Napoleon himself to lead 200,000 men into Spain. The British attacked near Burgos but were soon forced into a long retreat chased by the French and punctuated by battles at Sahagun, Benavente and Cacobelos, ending in a British evacuation from La Coruña in January 1809, Moore being killed while directing the defence of the town. Satisfied and after only little more than two months in Spain, Napoleon handed command over to Nicholas Soult and returned to France.
Wellesley returned to Portugal in Apil 1809 to command the Anglo-Portuguese forces. The re-organised force defeated Soult at Oporto (May 12) and advanced into Spain to join up with the army of Gregorio de la Cuesta. The combined Allied force clashed with a army led by King Joseph at Talavera (July 27-28), the Allies won a costly victory which left them precariously exposed and soon they had to retreat westwards. Wellesley was made a Viscount for his victory at Talavera. Later that year Spanish armies were badly mauled at Ocaña and at Alba de Tormes. Fearing the French attack Wellesley order the construction of defences along key roads and of a series of trenches and earthworks (the Lines of Torres Vedras) to protect Lisbon.
The French invaded Portugal in late 1810 with an army of around 60,000 led by Andre Masséna. The first significant clash was at Buçaco on September 27, the French were held but the Allies were soon forced to retreat to the Lines. The fortifications were so impressive that after a small attack at Sobral on October 14 the conflict fell into stalemate. The French withdrew from close to the Lines and were forced to wait.
The Allies were reinforced by the arrival of fresh British troops in early 1811 and began a new offensive. A French force was beaten at Barrosa on March 5 to relieve Cadiz, and Massena was forced to withdraw from Portugal after the stalemate at Fuentes de Oñoro (May 3-5). Massena was replaced by Auguste Marmont and the new commander directed Soult to the north to protect Badajoz. The force of Soult was intercepted by a mixed Allied force led by William Beresford at Albuera (May 16) and after a bloody battle the French were forced to retreat. The war then fell into a temporary lull, the numerically superior French unable to find an advantage and under increasing pressure from Spanish guerilla activity.
Wellesley renewed the Allied advance into Spain just after New Year in 1812, besieging and capturing Ciudad Rodrigo on January 19 and Badajoz, after a costly assault, on April 6, both towns were pillaged by the British troops. The Allied army took Salamanca on June 17 as Marmont approached. The two forces finally met on July 22 and the Battle of Salamanca was a damaging defeat to the French. As the French regrouped, Wellesley's men entered Madrid on August 6 and advanced onwards towards Burgos before retreating all the way back to Ciudad Rodrigo. The French hopes were then stricken by Napoleon's disastrous invasion of Russia in 1812, starved of reinforcements the French position became increasingly unsustainable as the Allies renewed the offensive in May 1813. Of the 300,000 French soldiers in Spain over 200,000 were scattered to deal with guerilla activity and to protect supply routes.
The Allied forces swept northwards in June and seized Burgos, then they outflanked the army commanded by Joseph forcing him into the Zadorra river valley. At the Battle of Vitoria (June 21) the army of Joseph was routed. The Allies chased the retreating French, reaching the Pyrenees in early July. Soult was given command of the French forces and began a counter-offensive, dealing the Allies two sharp defeats at Maya and at Roncesvalles but losing momentum after the Allied victory at Sorauren (July 28). On October 7 the Allies finally crossed into France, fording the Bidossa river.
The war in the Iberian Peninsula was geographically over, although the Allied victories at Bayonne (December 10-14), Orthez (February 27, 1814) and Toulouse (April 10) are generally included in the campaign.