Independence

In 1808, after Napoleon I had invaded Portugal, Prince Regent John (later King John VI) moved his court to Rio de Janeiro. In 1821 he returned to Portugal, leaving his son Dom Pedro (1798–1834) as regent of Brazil. Under the influence of one of his ministers, José Bonif´cio de Andrade e Silva, young Dom Pedro came to sympathize with the people's desire for independence from Portugal. In 1822 he declared Brazil independent and was crowned emperor of the country. He abdicated in 1831 in favor of his five-year-old son, Dom Pedro II. Dom Pedro II was represented by a regent until 1840, when he was proclaimed emperor at the age of 15. He reigned until 1889, when a republic was established after a bloodless coup.

Under the emperors, Brazil had fought two territorial wars with neighboring states. In the Argentine-Brazilian War (1825–28), both countries fought for the territory that is now Uruguay. The war ended with recognition of Uruguay's independence. In the War of the Triple Alliance (1865–70), Argentina, Brazil, and Uruguay united against Paraguay, which had been making territorial claims in that part of South America. Paraguay was soundly defeated.

In the mid-19th century a new wave of European immigrants, mostly from Italy and Germany, began to arrive in Brazil. In 1888 all slaves were declared free.

The new republic was dominated in its early years by the military forces who had led the coup that overthrew the emperor. After a decade of economic problems and many shifts in leadership within the military ruling group, Brazil prospered under three successive civilian presidents, 1898–1910. The army's power resurfaced in the 1910 election, when Hermes da Fonseca, an army-sponsored candidate, was elected.