Founded in 1565 by the Portuguese, the city was initially the seat of the Captaincy of Rio de Janeiro, a domain of the Portuguese Empire.
Later, in 1763, it became the capital of the State of Brazil, a state of the Portuguese Empire.
The region of Rio was inhabited by the Tupi, Puri, Botocudo and Maxakalí peoples.
In 1555, one of the islands of Guanabara Bay, now called Villegagnon Island, was occupied by 500 French colonists under the French admiral Nicolas Durand de Villegaignon.
Rio de Janeiro subsequently served as the capital of the independent monarchy, the Empire of Brazil, until 1889, and then the capital of a republican Brazil until 1960 when the capital was transferred to Brasília.In the first decades, several educational establishments were created, such as the Military Academy, the Royal School of Sciences, Arts and Crafts and the Imperial Academy of Fine Arts, as well as the National Library of Brazil - with the largest collection in Latin America When Brazil was elevated to Kingdom in 1815, it became the capital of the United Kingdom of Portugal, Brazil and the Algarves until the return of the Portuguese Royal Family to Lisbon in 1821, but remained as capital of the Kingdom of Brazil.From the colonial period until the first independent decades, Rio de Janeiro was a city of slaves.Sebastian, the saint who was the namesake and patron of the then Portuguese Monarch Sebastião. Until early in the 18th century, the city was threatened or invaded by several, mostly French, pirates and buccaneers, such as Jean-François Duclerc and René Duguay-Trouin.In the late 17th century, still during the Sugar Era, the Bandeirantes discovered gold and diamonds in the neighbouring captaincy of Minas Gerais, thus Rio de Janeiro became a much more practical port for exporting wealth (gold, precious stones, besides the sugar) than Salvador, Bahia, which is much farther to the northeast.It was the main stage of the abolitionist and republican movements in the last half of the 19th century.