Dom Pedro I, nicknamed "the Liberator", was the founder and first ruler of the Empire of Brazil. As King Dom Pedro IV, he reigned briefly over Portugal, where he also became known as "the Liberator" as well as "the Soldier King". Born in Lisbon, Pedro I was the fourth child of King Dom João VI of Portugal and Queen Carlota Joaquina, and thus a member of the House of Braganza. When the country was invaded by French troops in 1807, he and his family fled to Portugal's largest and wealthiest colony, Brazil.
The outbreak of the Liberal Revolution of 1820 in Lisbon compelled Pedro I's father to return to Portugal in April 1821, leaving him to rule Brazil as regent. He had to deal with challenges from revolutionaries and insubordination by Portuguese troops, all of which he subdued. The Portuguese government's threat to revoke the political autonomy that Brazil had enjoyed since 1808 was met with widespread discontent in Brazil. Pedro I chose the Brazilian side and declared Brazil's independence from Portugal on 7 September 1822. On 12 October, he was acclaimed Brazilian emperor and by March 1824 had defeated all armies loyal to Portugal.