The Peninsular War (1807–1814) was a war between the first French Empire and the Spanish Empire for control of what is now Spain and Portugal. The war began when French and Spanish armies invaded and occupied Portugal in 1807. It became more serious in 1808 when France attacked Portugal's ally Spain, and made Joseph Bonaparte its king. General Sir Arthur Wellesley, later Arthur Wellesley, 1st Duke of Wellington, became famous in the war. The war lasted until certain European states joined together in the Sixth Coalition and defeated Napoleon in 1814.