Even before Austria's attempt to regain autonomy during the Napoleonic Wars, Napoleon (1769-1821) encountered trouble on the Iberian peninsula -- trouble that would end only with his reign. When Britain's ally Portugal rejected the Continental System (a trade boycott initiated by Napoleon against Britain), Napoleon secured permission to invade Portugal via Spain. Ensuing Spanish discontent led King Charles IV (1748-1819) of Spain to abdicate in 1808 in favor of his son King Ferdinand VII (1784-1833), who was received enthusiastically by the people. Napoleon, however, forced Ferdinand and return the crown to his father, who then resigned his rights to the French emperor, whereupon Napoleon crowned his own brother, Joseph Bonaparte (1768-1844), sparking a national uprising backed by Britain. The French, after setbacks at Bailen and Vimeiro in 1808, surrendered Lisbon. Then Napoleon himself took command of the French forces and nearly defeated the British, who narrowly escaped at Coruna in early 1809. That year, with France preoccupied in Austria, the British under Sir Arthur Wellesley, Lord Wellington (1769-1852), returned to drive the French from Portugal and invade Spain, overcoming the French at Talavera on July 28, 1809. But Napoleon's reinforcements restored French ascendancy. In 1811 Wellington's forces began their inexorable recovery of Portugal's frontier fortresses. They proceeded to Salamanca and Madrid, evicting the French from southern Spain in 1812. Wellington failed to take Burgos but in 1813 routed the French at Vitoria and pursued them back into France, where he laid siege to Bayonne and Bordeaux, his actions merging with the general allied liberation effort. The Peninsular War brutalized Spain and detonated revolutions throughout Latin America.