The French army occupied Spain after Napoleon decided to conquer the country in 1808, sparking the Spanish War of Independence. The war ended in 1814 with Spain defeating France with British help. During the war, Spain had two governments - one led by Joseph I (Napoleon's brother) that controlled most of Spain, and another led by Fernando VII that was based in Cádiz. In 1812, the Cádiz government approved Spain's first liberal constitution called the Constitution of Cádiz, influenced by French Revolutionary ideals. When Fernando VII returned to power in 1814, he abolished the constitution and restored the absolute monarchy.