Brazil gained its independence on September 7th, 1822, when Dom Pedro proclaimed Brazil's independence after an antagonistic relationship with Portugal proved too much for the Brazilian people. It all began when Napoleon I invaded Portugal in 1807.
After the invasion, the Portuguese prince fled to Brazil with the help of the British. The new prince, Dom Joao, was warmly welcomed in Brazil as he abolished the Portuguese commercial monopoly on Brazil's trade, opened Brazil's harbors and allowed Brazil to manufacture goods once again. On December 16, 1815, he redesignated the Portuguese dominions to the title of the United Kingdom of Portugal, Brazil and the Algarves. This made Brazil equal to Portugal in power and rights.
However, Dom Joao's mother died and he then ascended the throne. On April 22, 1821, the son of King John VI, Dom Pedro, was sent to Brazil. The relations between the Portuguese and Brazilian people had become antagonistic at this point and the Brazilian people in Cortes, or parliament, wanted to return to the prior colonial status under France.
The Cortes ordered Dom Pedro to go home because they feared an independent movement. Dom Pedro refused. He gave a famous speech known as "I Am Staying" and soon Brazilians were rallying around Dom Pedro with his ideas of independence for Brazil. He formed a ministry in January of 1822. On June 3, 1822, he created a legislative and constituent assembly. Once Brazil proclaimed its independence on September 7, 1822, Dom Pedro was crowned emperor on December 1, 1822. It only took slightly more than a year, in 1824, for the United States to officially recognize Brazil as a new independent nation.