The land now called Brazil was claimed by the Kingdom of Portugal in April 1500, on the arrival of the Portuguese naval fleet commanded by Pedro Álvares Cabral. The Portuguese encountered Indigenous nations divided into several tribes, most of whom shared the same Tupi-Guaraní language family, and shared and disputed the territory.
Though the first settlement was founded in 1532, colonization was effectively started in 1534 when King John III divided the territory into fifteen hereditary captaincies. This arrangement proved problematic, however, and in 1549 the king assigned a Governor-General to administer the entire colony. The Portuguese assimilated some of the native tribes while others slowly disappeared in long wars or by European diseases to which they had no immunity..
By the mid-16th century, sugar had become Brazil's most important export due to the increasing international demand for sugar. To profit from the situation, by 1700 over 963,000 African slaves had been brought across the Atlantic Ocean to work in the plantations of Brazil. More Africans were brought to Brazil up until that date than to all the other places in The Americas (Western Hemisphere) combined.
Through wars against the French, the Portuguese slowly expanded their territory to the southeast, taking Rio de Janeiro in 1567, and to the northwest, taking São Luís in 1615. They sent military expeditions to the northwest of the South American continent to the Amazon River basin rainforest and conquered competing English and Dutch strongholds, founding villages and forts from 1669. In 1680 they reached the far southeast and founded Sacramento on the bank of the Rio de la Plata, in the Banda Oriental region (present-day Uruguay).
At the end of the 17th century, sugar exports started to decline, but beginning in the 1690s, the discovery of gold by explorers in the region that would later be called Minas Gerais (General Mines) in current Mato Grosso, Goiás and the Brazilian state of Minas Gerais saved the colony from imminent collapse. From all over Brazil, as well as from Portugal, thousands of immigrants came to the mines in an early "gold rush".
The Spanish tried to prevent Portuguese expansion northwest, west, southwest and southeast into the territory that belonged to them according to the 1494 Treaty of Tordesillas division of the New World of The Americas by the Bishop and Pope of Rome, Pope Alexander VI (1431-1503, reigned 1492-1503) and succeeded in conquering the Banda Oriental region in 1777. However, this was in vain as the Treaty of San Ildefonso, signed in the same year, confirmed Portuguese sovereignty over all lands proceeding from its territorial expansion, thus creating most of the current Brazilian southeastern border.
During the French invasion of Portugal, by Emperor Napoleon I in 1807, the Portuguese royal family House of Braganza fled across the Atlantic Ocean with the help of the British Royal Navy to Brazil, establishing Rio de Janeiro as the de facto capital of Portugal and Brazil and the Portuguese Empire during the ensuing worldwide Napoleonic Wars (1803-1815). This had the side effect of soon creating within Brazil, many of the institutions required to exist as an independent state; most importantly, it freed Brazil to trade with other nations at will.
After Napoleon's Imperial French army was finally defeated at Waterloo in June 1815, in order to maintain the capital in Brazil and allay Brazilian fears of being returned to colonial status, King John VI of Portugal raised the de jure status of Brazil to an equal, integral part of a new status in a United Kingdom of Portugal, Brazil, and the Algarves, rather than a mere colony, a status which it enjoyed for the next seven years, sending his son, Dom Pedro as prince regent.