The city is capital of the state of Rio de Janeiro. It was the capital of Brazil for almost two centuries—from 1763 to 1822 while it was a Portuguese colony and from 1822 to 1960 as an independent nation. It was the de facto capital of the Portuguese Empire from 1808 to 1821.
The city was founded on March 1, 1565, by Portuguese knight Estácio de Sá, who called it São Sebastião do Rio de Janeiro 20 (St Sebastian of the January 20th River), in honour of Saint Sebastian (day of death traditionally on January 20). For centuries, the settlement was commonly called São Sebastião — or even ‘Saint Sebastian’ — instead of the currently popular second half of its name. The city was founded as a base from which to invade the French settlement. They succeeded in 1567 and the French were expelled. Later, São Sebastião was frequently attacked by pirates and privateers, especially by then enemies of Portugal, such as the Netherlands and France.
In the late 16th century, the Portuguese crown began treating the village as a strategic location for the Atlantic transit of ships between Brazil, the African colonies and Europe. Fortresses were built and an alliance was formed with nearby native tribes to defend the settlement. Invaders — Rio’s neighbor, Niterói, for instance, was founded by Araribóia, a Tamoio Indian chief, for defensive purposes. Sugar cane was the first industry in the area. First native, and later African, slaves were used for manual labor. Eventually the industry dwindled as higher quality sugar cane from northern Brazil became more available.
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. After 1720, when the Portuguese found gold and diamonds in the neighboring captaincy of Minas Gerais, Rio de Janeiro became a much more useful port for exporting wealth than Salvador, Bahia, which is much farther to the north. In 1763, the colonial administration in Portuguese America was moved to Rio. The city remained primarily a colonial capital until 1808, when the Portuguese Royal Family and most of the associated Lisbon nobles, fleeing from Napoleon’s invasion of Portugal, moved to Rio de Janeiro. The kingdom’s capital was transferred to the city, which, thus, became the only European capital outside of Europe. As there was no physical space or urban structure to accommodate hundreds of noblemen who arrived suddenly, many inhabitants were simply evicted from their homes.
When Prince Pedro I proclaimed the independence of Brazil in 1822 (by saying the famous “Independence or death!”), he decided to keep Rio de Janeiro as the capital of his new empire. Rio continued as the capital of Brazil after 1889, when the monarchy was replaced by a republic.