Brazilian War of Independence

The Brazilian War of Independence was waged between the Brazilian Empire and the Portuguese Empire from February 1822 until 8 March 1824, when Montevideo fell to the Brazilians. Portugal lost its largest possession, even bigger than their home country, and Dom Pedro I of Brazil founded a new nation that encompassed Brazil as well as Uruguay (until the Cisplatine War).

Background
The American Revolutionary War of 1775-1783 proved that the world's strongest power, Great Britain, could not defeat a force of rabble who fought a long guerrilla war. The independence of the United States in 1783 led to a shockwave of revolutions, starting with the Kingdom of France in 1789, then in Spain in 1808. Spain's occupation by the French during the Napoleonic Wars weakened Spain's colonial empire of New Spain, and Spain's South American possessions revolted, facing only Royalist troops; Spain was tied down in liberating their own country. The rebels had liberated their lands by 1826, but before then, the Brazilians had conceived ideas of gaining independence from Portugal. Inspired by poet Jose Bonifacio and led by Dom Pedro, the Brazilians rallied in large numbers.

War
When news came to Campo Maior that Joao Jose de Cunha Fidie and 1,600 Portuguese troops were bound to Oeiras, Leonardo Castelo Branco and 2,000 Brazilian militia blocked them near Piaui. The Brazilians were swept by cannon fire and musketry, and 200 of the rebels were killed, with 542 prisoners. 176 Portuguese were killed or wounded, winning the Battle of Jenipapo.

A repeat of Jenipapo seemed imminent when Inacio Luis Madeira de Melo's 3,200 Portuguese troops engaged Pierre Labatut's 1,300 Brazilian Peacemaker Army troops in Bahia, but when the Brazilians sounded the "cavalry advance" instead of retreat bugle call (there was no cavalry), the Portuguese were confused and fled. Labatut pursued them and defeated them in the famed Battle of Piraja. At Itaparica and an action on 4 May, the Brazilian Navy won the war at sea with virtually no losses.

Madeira's forces retreated to the Bahia city of Salvador, and Labatut continued to fight with them even after Piraja, capturing the city. Soon, Montevideo and Caxias, the last two Portuguese strongholds, fell to the Brazilians, who gained their independence in 1824.

Aftermath
Brazil's capture of Montevideo in Cisplatina was reversed when the United Provinces of Rio de la Plata and Uruguayan rebels fought them in the Cisplatine War of 1828, securing Uruguay's independence from Brazil. Brazil continued to play a major role in South America's infant wars, fighting in the War of the Triple Alliance in the 1860s.