Napoleon pressured the Spanish royal family to abdicate in 1808, allowing him to place his brother Joseph on the Spanish throne and occupy Spain with French troops. This sparked the Spanish War of Independence as Spanish forces defeated the French at the Battle of Bailén in 1808. The war ended in 1813 with the Spanish approving their first constitution and Joseph I's reign concluding as French control over Spain dissolved.