When Napoleon occupied Portugal in 1807 and Spain in 1808, Britain found it necessary in August 1808 to come to the aid of these Iberian nations. The ensuing campaigns became known as the Peninsular War.
Allied with Spanish irregular forces, the British-Portuguese army forces led by General Sir Arthur Wellesley (later the Duke of Wellington) battled the French occupiers eastward across Spain for the next seven years. Although greatly outnumbered by the French they were forced to retreat on several occasions that allowed them to hold on despite these. But there were some victories such as that at Badajoz.
After Napoleon's catastrophic defeat in Russia the balance of forces in Spain changed and the allied armies were able to defeat the French occupiers, drive them across the Pyrenees into France and finally to Paris which they reached in March 1814.
There they joined the much larger forces of Prussia, Austria and Sweden which with Britain, Portugal and Spain comprised the Sixth Coalition of nations that was reconstituted after Napoleonžs retreat from Russia. Outnumbered, Napoleon was forced to abdicate on 6 April and was exiled to the island of Elba in May 1814.