Tens of thousands of Brazilians celebrated on Rio de Janeiro's Copacabana beach after the International Olympic Committee awarded the 2016 Olympic Games to the city.
Rio de Janeiro will host the 2016 Olympics after seeing off Madrid in the final round of voting among International Olympic Committee members on Friday. It will be the first South American city to host the Games.
The announcement was delayed by several seconds as IOC president Jacques Rogge struggled to open the envelope.
"Like in every competition there can only be one winner," Rogge told the nervous crowd.
"Tonight I have the honour to announce that the Games of the 31st Olympiad are awarded to .... the city of Rio de Janeiro."
The decision left Brazilian president Luiz Inacio Lula da Silva and much of the rest of the Brazil bid team, including footballer Pele, in tears.
Weeping into a handkerchief, Mr Lula said Brazil needs the Olympic Games and that while the other cities had presented a proposal, Brazil had presented its heart.
The delegation broke into singing their "Marvellous City" song, all waving flags and hugging each other.
President Lula said 2016 was an opportunity for the IOC to show that the Games belonged to people of all continents.
Afterwards, he said: "All those people who thought we had no ability to govern this country will now learn that we can host the Olympics."
President Lula has warned Brazilians they'll have to sleep less and work more if they're to fulfill their responsibility as the first South American country to host the games.
"This decision for me is proof that Brazil has finally been granted its international citizenship," he said. "We're no longer second class, we're now first class. There's no better and no worse, only equal. That's all we aspire to be, that's what this victory means to us."
Obama bid fails
In a surprise start to the voting, the odds-on favourite Chicago went out in the first round, despite receiving unprecedented support from United States President Barack Obama and the first lady, Michelle Obama.
It was a rebuff for Mr Obama, who had become the first sitting US president to address an IOC session.
Tokyo followed them out in the second round, leaving Madrid and Rio to fight it out in the final round. In the final round of voting, Rio polled 66 votes to 32 for the Spanish capital.
Build from scratch
Rio had the least-prepared infrastructure of the four cities competing for the spot.
It will have to build from scratch nearly half the stadium capacity it needs and carry out renovations to provide another 24 percent of the minimum required seating.
Rio has a limited metro system that does not link the city centre and most of its hotels to the outskirts of Barra da Tijuca, where the venues are concentrated.
And while the city is renowned for its natural wonders, including beaches and the Sugar Loaf mountain, it's also notorious for violent crime in its shantytowns, or 'favelas', driven largely by warring drug gangs.
However, Rio says it will spend heavily on its infrastructure.
President Lula said there was a lot of work ahead and Brazil would start working early.
Brazil is hosting the 2014 soccer World Cup and prepararations are underway for that event, including plans to upgrade the famous Maracana stadium.
Rugby sevens likely in 2016 Games
Golf and rugby sevens were provisionally included in the 2016 Olympics programme, after a vote by the International Olympic Committee's executive board in August.
The decision is expected to be rubber stamped at a full IOC meeting in Copenhagen next week.
The coach of the New Zealand sevens team Gordon Tietjens says the prospect of rugby sevens being played in Rio de Janiero is a fantastic one.
"They're really passionate sports people over there even though football's their main sport. But sevens rugby has got a lot of support so it would be outstanding having sevens in the Brazil games," he said.
Tietjens says the rugby community is doing everything it can ahead of next week's final vote to ensure sevens gets the final seal of approval.