Although the war against Spain and Portugal was essentially a by-game scenario for Napoleon, it did bind French forces that would have been needed more in Central Europe. In addition, France was exposed to a two-front war.
In 1804 Spain allied with France in the war against England. In 1806, after Napoleon had defeated the European powers Austria, Russia and Prussia, but was still at war with England, he imposed with the continental blockade an import ban for English goods on the European mainland.
Portugal, which so far had kept out of the conflict with France, was not anxious to comply with this barrier. Thus, the country was occupied by French troops, which were supported by Spain. The royal family of Portugal had to flee to Brazil in this context. Now Napoleon also attacked the Spanish crown and let his troops occupy important fortresses and Madrid until May 1808. He pressured the Spanish royal family of the Bourbons to abdicate and recognize his brother Joseph as king. All over the country this triggered riots and France had to send more soldiers.
The beginning of the uprisings:
The first major uprising took place on 2 May 1808 in Madrid, where the population rose against the French garrison stationed there. The rebellion was quickly but brutally suppressed by the soldiers, but could not prevent the uprisings from spreading throughout the country. The provincial councils immediately began to build up and organize military resistance against the occupiers. Already in July, a whole French army corps surrendered with around 20,000 men when it was encircled by the Spanish militia at Bailen.
Since England at that time was militarily unable to oppose the French mainland on the French troops, in return a smaller expeditionary corps led by Arthur Wellesley was sent to Portugal to fight against the weaker French troops there support. With the intervention of the English, the Portuguese succeeded in Vimeiro to move the French troops of Marshal Junots to surrender. Junots saw himself encircled between the Spaniards, English and Portuguese and negotiated with Wellesley his surrender on condition that his soldiers could be shipped along with all the equipment to France.
To bring the situation in Spain and Portugal back under control, Napoleon decided to send another army under his leadership to Spain. He succeeded in recapturing Madrid and turned back to Portugal to smash the English army. The now under the leadership of Sir John Moore standing English army had to save the French attacks on the northwest coast of Spain, from where it was evacuated in 1809 by La Coruna with the help of the Royal Navy. Napoleon saw his claim to Spain again secured and hastened back to France, because Austria had again declared war on him.
The offensives of the English and Spaniards:
The French claims to the peninsula soon evaporated when the Spanish soldiers resisted more than they thought and the British, led by Arthur Wellesley, again prevented the French invasion of Portugal. Although an Anglo-Spanish counter-offensive brought Talavera to victory, the troops had to retreat back to Portugal for advancing French forces, preparing for the counterattack.
But this counter-offensive did not take place, because the French troops were numerically superior, but widely scattered across the country. In addition, the supply of troops through the conquered territories was increasingly difficult and the French were faced with loss-making battles with Spanish guerrillas.
Only in 1810 could the French troops under Marshal Masséna again carry out a campaign to Portugal. But this ended in September before Torres Vedras, where the French failed to storm the strong fortifications. In the spring of 1811, the Marshal had to pull back to Spain due to the supply problems. Wellington (formerly Wellesley, before being elevated to the peerage) cautiously followed the Frenchman. In May 1811, Fuentes de Onoro and Albuerra faced lossy battles that ended in a draw. Subsequently, the siege of the border fortresses Ciudad Rodrigo and Badajoz began. Rodrigo fell in January and Badajoz in April 1812.
The English invasion in southern France:
After the conquest of the frontier fortress Wellington swung north, where he struck Marshall Marmont at Salamanca in July. The French withdrew their troops from Madrid to use against the Wellington army. Despite the English successes, the balance of power was still 2 to 1, from French to English. But the Spanish guerrillas continued to inflict more and more on the French troops and the morale of the troops began to break.
In the spring of 1813 Wellington began a new offensive and marched with his troops towards the Spanish-French border. In June, he defeated a French army led by Napoleon's brother Joseph and crossed the Pyrenees to France with his troops in October.
When Napoleon abdicated in France in April 1814, Wellington's troops were already in Toulouse.