The land now called Brazil was claimed by Portugal in April 1500, on the arrival of the Portuguese fleet commanded by Pedro Álvares Cabral. The Portuguese encountered stone age natives divided into several tribes, most of whom spoke languages of the Tupi–Guarani family, and fought among themselves. Though the first settlement was founded in 1532, colonization was effectively begun in 1534, when King Dom João III of Portugal divided the territory into twelve hereditary captaincies, but this arrangement proved problematic and in 1549 the king assigned a Governor-General to administer the entire colony. The Portuguese assimilated some of the native tribes while others were enslaved or exterminated 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 and the Portuguese imported African slaves to cope with the increasing international demand.
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 Amazon rainforest and conquered British and Dutch strongholds, founding villages and forts from 1669. In 1680 they reached the far south and founded Sacramento on the bank of the Rio de la Plata, in the Eastern Bank region. 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 in current Mato Grosso and Goiás, saved the colony from imminent collapse. From all over Brazil, as well as from Portugal, thousands of immigrants came to the mines. The Spanish tried to prevent Portuguese expansion into the territory that belonged to them according to the 1494 Treaty of Tordesillas, and succeeded in conquering the Eastern Bank in 1777. However, this was in vain as the