The 2012 Olympic Games will be held in London, the International Olympic Committee has announced.
London won a two-way fight with Paris by 54 votes to 50 at the IOC meeting in Singapore, after bids from Moscow, New York and Madrid were eliminated.
Prime Minister Tony Blair called the win "a momentous day" for Britain.
Paris had been favourites throughout the campaign but London's hopes were raised after an impressive presentation by Lord Coe, the bid chairman.
IOC president Jacques Rogge made the dramatic announcement at 1249 BST.
It will be the first time the Olympics has been held in Britain since 1948.
Coe said: "This is just the most fantastic opportunity to do everything we ever dreamed of in British sport."
The Queen, in a message to Coe, said: "I send my warmest congratulations to you and every member of the London 2012 team for winning the bid for the UK.
"It's a really outstanding achievement to beat such a highly competitive field."
After the announcement, it emerged London was ahead in every round of voting except the second round when Madrid polled the most votes.
HOW VOTE UNFOLDED
Round 1: Moscow out
Round 2: New York out; Madrid lead in tight poll
Round 3: Madrid out
Round 4: London 54-50 Paris
News of London's victory delighted flag-waving supporters who had gathered in Trafalgar Square and Stratford in the East End of London, where the new Olympic park will be built.
Shares of British construction companies soared, while mortgage lenders predicted house prices in the capital would rocket.
But raindrops began falling on disappointed Parisians outside the Hotel de Ville in the French capital shortly after the result.
Mr Blair had helped London's late momentum with a whistlestop 48-hour visit to Singapore, before flying back for the G8 summit in Scotland.
Breaking off from the meeting of world leaders, he said of London: "Many reckon it is the greatest capital city in the world and the Olympics will help keep it that way."
Rogge had correctly forecast a cliffhanger vote, and offered his congratulations to the winners.
"We knew the two bids were very, very close. Well done, London. It will be a superb Games and will strengthen the Olympics," he said.
An hour after the decision, London's bid leaders were greeted by warm applause as they signed the official contract to stage the Games.
This is how the decision was made by the IOC in Singapore on Wednesday:
- All five bidding cities gave final 45-minute presentations to the IOC members before the vote began.
- The electronic ballot started at 1126 BST. Moscow, New York and Madrid were eliminated from the race in the first, second and third rounds of voting.
- The final round of voting finished at about 1145 BST, with the committee reconvening at 1230 BST for the official announcement.
- Rogge revealed the winner, after a nerve-wracking wait, at 1249 BST.
Wednesday's decision brings to an end the 18-month race to win the host contract for the 2012 Games.
And it was the most keenly-fought bidding contest in recent years.
Paris was considered the front-runner for much of the campaign, and was highly rated in the initial evaluation and also by the inspectors after their visits earlier in the year.
But it was widely recognised that bid leader Lord Coe, a high-profile personality within the IOC and other governing bodies, hauled London closer to the French capital as the vote approached.
Madrid was seen as a consistent but not outstanding candidate, while New York's bid was dogged by problems over their proposed stadium, and Moscow was always seen as the rank outsider.
Once attention moved to Singapore, the bidding cities called on political and sporting heavyweights to champion their causes.
And the spotlight inevitably focused on Paris and London in the days leading up to the vote.
The two cities had President Chirac and Prime Minister Blair respectively in their corners.
Mr Chirac actually took part in the French capital's final presentation on Wednesday, while Mr Blair opted to lobby alongside the London bid team in Singapore before flying back to Britain to host the G8 summit.
London also called on England captain David Beckham and a galaxy of Olympic and Paralympic medallists as ambassadors, while footballers Laurent Blanc and Zinedine Zidane were among those backing the Paris bid.