Brazil became independent in a peaceful way compared with other South-American countries. This was because the Portuguese Court, fleeing the Napoleonic invasion in Portugal, moved their capital from Lisbon to Rio de Janeiro, which thus became the new capital of the Portuguese Empire. The Portuguese king, João VI, ruled his huge empire from here for 15 years. He left his son, Pedro, in his stead as regent of Brazil when he returned to Portugal in 1821. Pedro decided one year later that Brazil should secede from Portugal and instituted a constitutional monarchy headed by himself as Emperor Pedro I of Brazil. He abdicated in 1831 and also returned to Portugal, leaving behind his five-year-old son as Emperor Pedro II. When the son was declared of age and assumed his full prerogatives, he 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.