After being on the defensive, Wellington went on the offensive. He continued to push into Spain until he reached the French border, where he met heavy resistance until Napoleon abdicated in 1814 ending the Peninsular War.
After Napoleon replaced the Spanish King with his brother Joseph in 1808, he had to send troops into Spain and Portugal to suppress the rebellions. However, British forces (red) landed near Lisbon and defeated the French forces there. The defeat caused the French (green) to retreat back into Spain. Although there were several attempts, the French never conquered Portugal again.