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. In 1808, when the Portuguese Royal Court transferred itself from Portugal to Brazil, Rio de Janeiro became the chosen seat of the court of Queen Maria I of Portugal, who subsequently, in 1815, under the leadership of her son, the Prince Regent, and future King João VI of Portugal, raised Brazil to the dignity of a kingdom, within the United Kingdom of Portugal, Brazil, and Algarves. Rio stayed the capital of the pluricontinental Lusitanian monarchy until 1822, when the War of Brazilian Independence began. This is one of the few instances in history that the capital of a colonising country officially shifted to a city in one of its colonies. 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.
Europeans first encountered Guanabara Bay on 1 January 1502 (hence Rio de Janeiro, "January River"), by a Portuguese expedition under explorer Gaspar de Lemos , captain of a ship in Pedro Álvares Cabral 's fleet, or under Gonçalo Coelho .  Allegedly the Florentine explorer Amerigo Vespucci participated as observer at the invitation of King Manuel I in the same
expedition. The region of Rio was inhabited by the Tupi , Puri, Botocudo and Maxakalí peoples.