History of Portugal (1834–1910)
Militant Republicans and their allies in the Carbonária were not willing to remain in the shadows of the constitutional monarchy. Between 4–5 October 1910, members of the Carbonária, republican youth, and elements of the army instigated a coup d'état against the already weak constitutional monarchy. The young king and his family, after a few miscues, escaped from the Palace in Mafra to exile in England. On the morning of 5 October 1910, the Republic was declared from the balcony of Lisbon City Hall, ending eight centuries of monarchy in Portugal.
Brazil
With the end of the Peninsular War in 1814, the courts of Europe demanded that Queen Maria I and Prince Regent João return to Portugal, deeming it unfit for the head of an ancient European monarchy to reside in a colony. In 1815, to justify continuing to live in Brazil, where the royal court had thrived for the prior six years, the Crown established the United Kingdom of Portugal, Brazil, and the Algarves, thus creating a pluricontinental transatlantic monarchic state. However, such a ploy didn't last long, since the leadership in Portugal, resentful of the new status of its larger colony, continued to require the return of court to Lisbon (as postulated by the Liberal Revolution of 1820), and also groups of Brazilians, impatient for practical and real changes, still demanded independence and a republic, as demonstrated by the 1817 Pernambucan Revolt.
In 1821, as a demand of revolutionaries who had taken the city of Porto, D. João VI was unable to hold out any longer, and departed for Lisbon. There he swore an oath to the new constitution, leaving his son, Prince Pedro de Alcântara, as Regent of the Kingdom of Brazil.