The independence of Brazil comprised a series of political and military events that led to the independence of the Kingdom of Brazil from the United Kingdom of Portugal, Brazil and the Algarves as the Brazilian Empire. It is celebrated on 7 September, the date when prince regent Pedro of Braganza declared the country's independence from the United Kingdom of Portugal, Brazil and the Algarves on the banks of the Ipiranga brook in 1822 on what became known as the Cry of Ipiranga. Formal recognition by Portugal came with the Treaty of Rio de Janeiro, signed in 1825.
In 1807, the French army invaded Portugal, which had refused to participate in the continental blockade against the United Kingdom. Unable to resist the invasion, the Portuguese royal family and government fled to Brazil, which was then the richest and most developed of the Portuguese colonies. The installation of the House of Appeals and other public bodies of the Portuguese government in Rio de Janeiro represented a series of political, economic and social transformations that led to then prince regent John of Braganza (later king John VI of Portugal), to elevate the State of Brazil to the status of a kingdom on 16 December 1815, united with its former metropolis.