In 1820, Portugal experienced the Constitutional Revolution, which was initiated by the liberal constitutionalists. This revolution led to the Constituent Assembly’s meeting and deciding to create the first constitution of the Kingdom and to demand the return of King Dom João VI from Brazil. The assembly is also known as the Cortes. On 26 April 1821, the king left Brazil in the hands of his son, the newly elected Prince Regent, Dom Pedro, and returned to Portugal.
Dom Pedro I around age 35.
The Portuguese military officers that were based in Brazil at this time sided with the constitutionalist movement in their homeland. General Jorge Avilez, who led the Portuguese military, forced Dom Pedro to dismiss and banish the ministers of Kingdom and Finance. These men had both been loyal to Dom Pedro and the prince was left feeling helpless and humiliated as he was manipulated by Avilez. From that moment, Pedro swore never to give in to military manipulation again.
In September 1821, the provincial governments of Brazil were put in political subordination to Portugal, which left Pedro nothing more than the Governor of Rio de Janeiro, which was just a province. Pedro was also ordered to go back to Europe and any courts that his father had created in 1808 were done away with. The Brazilian inhabitants had, by this stage, become completely outraged by the Cortes’ actions. This resulted in the uprising of the Bonificans (led by Bonifácio de Andrade) and the Liberals (supported by the Freemasons and led by Joaquim Gonçalves Ledo). These two groups were united only by the fact that they wanted to keep Brazil united with Portugal as a sovereign monarchy.
As the open mockery and humiliation of Dom Pedro continued at the hands of the Cortes, the prince drew further and further away from his homeland, gradually shifting his loyalties to Brazil. Then, with the encouragement of his wife, Princess Leopoldina, Pedro made this announcement in the newspapers of 9 January 1822: “As it is for the good of all and for the nation’s general happiness, I am ready: Tell the people that I will stay”.
Pedro dismissed Jorge Avilez, who had instigated armed riots in response to Pedro’s announcement, ordering him and his soldiers back to Portugal. Jose Bonifácio was made the Minister of Kingdom and Foreign Affairs in January 1822, and he and Pedro soon became very close, both personally and politically.
In August 1822, Pedro went to São Paulo to pledge loyalty to the Brazilian cause. Upon his return to Rio de Janeiro in September, he received a letter from José Bonifácio informing him that the Cortes had cancelled all acts from the Bonifácio cabinet and had stripped him of all the power he retained. This was the last straw for Pedro. He addressed his friends and Guard of Honour, informing them that any ties that they had once held with Portugal were now broken. He instructed them to remove their blue and white armbands (symbolising their ties to their Mother Land), and said, “Hail to the independence, to freedom and to the separation of Brazil. For my blood, my honour, my God, I swear to give Brazil freedom. Independence or death!”
Word of the independent Brazil spread quickly, and locals celebrated the stance taken by Dom Pedro. The official breaking of ties occurred on 22 September 1822, when Pedro wrote a letter to his father, João VI. On 12 October 1822, Prince Pedro was acclaimed Dom Pedro I, Constitutional Emperor and Perpetual Defender of Brazil.
Here is the timeline for Brazilian Independence supplied by Google: Brazilian Independence timeline