 At the Battle of Vitoria in 1813, an allied army under the Duke of Wellington decisively defeated the French and in 1814 Ferdinand VII was restored as King of Spain.Spain lost all of its North and South American colonies, except Cuba and Puerto Rico, in a complex series of revolts 1808–26.Spain was at war with Britain 1798–1808, and the British Navy cut off its ties to its colonies.