Gaspar de Lemos set sail from Portugal for Brazil in 1501 and entered a huge bay in January 1502. Mistaking it for a river, he named it Rio de Janeiro. It was the French, however, who first settled permanently here. The Portuguese, like the French, harvested brazil wood along the Brazilian coast, and as Portuguese colonisation began to take hold, the French became concerned about being pushed out.
In 1555 three ships full of French settlers reached the Baía de Guanabara and settled on a small island they called Antarctic France. It didn't take long for the weak new town to come under attack from the Portuguese. They finally expelled the French from the region in 1560, also driving out the powerful Tamoio Indians, who allied with the French, in a series of grisly battles.
The founding Cariocas set up a fortified town on the Morro Castelo in 1567 called São Sebastião do Rio de Janeiro. It was a typical Brazilian town: poorly planned, with irregular streets in medieval Portuguese style. By the end of the century the settlement was getting by on fishing and the export of brazil wood and sugar cane. In 1660 the population was made up of 3000 Indians, 750 Portuguese and 100 blacks, but was still Brazil's third most important settlement. Slaves were brought in and sugar plantations - and their owners - thrived.
A gold rush in Minas Gerais at the start of the 18th century - ending half a century later when the gold ran dry - changed Rio forever, and Rio became the prize of Brazil. In 1710 the French, who were raiding the Portuguese colonies, attacked the city. The French were defeated at first, but a second try succeeded and the entire population fled the city in the dark of the night. The French demanded sizeable piles of gold, sugar and cattle, and the Portuguese had no choice but to oblige. However, the victorious French were brought down a few notches when two of their returning ships, filled with gold, were lost in treacherous storms.
Rio bounced back, replacing Salvador de Bahia as the colonial capital in 1763. In 1808 the entire Portuguese monarchy and court arrived in Rio, and so it was that the city came to house what was left of the Portuguese Empire. With the court came a heap of money and skills that were used to build some of the city's lasting monuments. The coffee boom in the mountains of São Paulo and Rio revitalised the economy, and the city took on a new importance as a port town and commercial centre. Passenger ships began sailing to London in 1845 and to Paris in 1851, and by the end of the 19th century, the city's population exploded due to European immigration and internal migration.