Brazil was one of only three modern states in the Americas to have its own indigenous monarchy (the other two were Mexico and Haiti) - for a period of almost 90 years. In an unusual reversal, Brazil, rather than Portugal itself, was the metropole of the Portuguese Empire from 1808 to 1821.
In 1808, the Portuguese court, fleeing from Napoleon's invasion of Portugal during the Peninsular War in a large fleet escorted by British men-of-war, moved the government apparatus to its then-colony, Brazil, establishing themselves in the city of Rio de Janeiro. From there the Portuguese king ruled his huge empire for 13 years, and there he would have remained for the rest of his life if it were not for the turmoil aroused in Portugal due, among other reasons, to his long stay in Brazil after the end of Napoleon's reign.
In 1815 the king vested Brazil with the dignity of a united kingdom with Portugal and Algarves. When king Jo„o VI of Portugal left Brazil to return to Portugal in 1821, his elder son, Pedro, stayed in his stead as regent of Brazil. One year later, Pedro stated the reasons for the secession of Brazil from Portugal and lead the Independence War, instituted a constitutional monarchy in Brazil assuming its head as Emperor Pedro I of Brazil.
Also known as "Dom Pedro I", after his abdication in 1831 for political incompatibilities (displeased, both by the landed elites, who thought him too liberal and by the intellectuals, who felt he was not liberal enough), he left for Portugal leaving behind his five-year-old son as Emperor Pedro II, which led the country ruled by regents between 1831 and 1840. This period was beset by rebellions of various motivations, such as the Sabinada, the War of the Farrapos, the MalÍ Revolt, Cabanagem and Balaiada, among other. After this period, Pedro II was declared of age and assumed his full prerogatives. Pedro II started a more-or-less parliamentary reign which lasted until 1889, when he was ousted by a coup d'ťtat which instituted the republic in Brazil.
Externally, apart from the Indepence war, stood out decades of pressure from the United Kingdom for the country to end its participation in the Slave Traffic and the wars fought at the region of La Plata river: the Cisplatine War (in 2nd half of 1820's), the War against Oribe & Rosas (in 1850's), the War against Aguirre and the Great War of La Plata (in 1860's). This last war against Paraguay also was the bloodiest and most expensive in South American history, after which the country entered a period that continues to present day, averse to external political and military interventions.