 During the French invasion of Portugal, by Emperor Napoleon I in 1807, the Portuguese royal family House of Braganza fled across the Atlantic Ocean with the help of the British Royal Navy to Brazil, establishing Rio de Janeiro as the de facto capital of Portugal and Brazil and the Portuguese Empire during the ensuing worldwide Napoleonic Wars (1803-1815).This had the side effect of soon creating within Brazil, many of the institutions required to exist as an independent state; most importantly, it freed Brazil to trade with other nations at will.After Napoleon's Imperial French army was finally defeated at Waterloo in June 1815, in order to maintain the capital in Brazil and allay Brazilian fears of being returned to colonial status, King John VI of Portugal raised the de jure status of Brazil to an equal, integral part of a new status in a United Kingdom of Portugal, Brazil, and the Algarves, rather than a mere colony, a status which it enjoyed for the next seven years, sending his son, Dom Pedro as prince regent.