The result triggered scenes of jubilation in Trafalgar Square and east London, where people had gathered to follow events on the other side of the world on big screens.
Tony Blair, David Beckham, the Queen and Prince William were among those who welcomed the news. London beat Paris to the prize after months of determined campaigning which went right down to the wire.The British and French capitals made it to the final round of voting after first Moscow, then New York and Madrid were eliminated in earlier rounds.
London managed to attract enough support from delegates to beat firm favourite Paris in the run-off.
The bid organisers surged ahead after a slick and forceful final presentation earlier today.
In it, bid leader Lord Coe promised a Games where "magic happens" .Commenting on the result, the London 2012 bid chairman and a double Olympic champion, said "the quality of the bid and vision of the bid and the fact that we've got London" helped clinch it."This is our moment," Lord Coe added.
Mr Blair, who arrived back from Singapore this morning after spending three days backing the bid, praised the "awesome" London team. He said: "This is a momentous day for London."
The Queen, in a message to Lord 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."
The victory means that London will play host to the world's premier sporting event in seven years' time with a specially-built stadium and village rising from what is now an urban wasteland in the east of the city.
Mayor of London Ken Livingstone said: "This is one of the best days London has ever had - and it is one of the proudest days for Britain and for British sport. We had the confidence to go for it and we have won the greatest prize in sport."
Prince William, who is on a tour of New Zealand, said: "I'm absolutely delighted that London has won the 2012 bid and I'm looking forward to what I'm sure will be a fantastic Olympic Games."Sports Minister Richard Caborn, who was in Singapore with the bid team, revealed how close the final vote was.
He said that London won by four votes - 54 to 50.Culture Secretary Tessa Jowell, also in Singapore, said London had "come from nowhere".
She added: "I really want to say thank you. There have been thousands of people involved in this."
She also praised the support of "millions of people back home." That's what's made the difference," she added.Rower Sir Matthew Pinsent said he was still "floating" from the result.
Propping himself up against a wall because he was so drained by the excitement of the result, he said: "I'm just shocked.
"It has been such hard work and Seb (Coe) has put his life into it."Details of London's final presentation were still being worked on just hours before it was delivered.
As the result was announced, Sir Matthew said was convinced that London had lost.
He said: "For some reason I was thinking Paris had got it. All the world's press and cameras were pointed towards Paris."We wanted this for the country and for the city and for the next generation of young people.
"It is incredible to believe that it has actually happened." England captain David Beckham, who spoke in Singapore yesterday of the prospect of the games taking place on his east London "manor", compared the capital's victory to winning the European Cup.
The Princess Royal, a member of the IOC and the London bid team, said: " If you listen to what the senior athletes said it's worth bearing in mind they were all inspired very early by watching things like the Games - the potential is enormous."
The result will be a major disappointment for French president Jacques Chirac, whose visit to Singapore to give a last-minute boost to the Paris bid yesterday was somewhat overshadowed by reported jibes he made at the weekend about the UK.
Mr Chirac made undiplomatic jokes about mad cow disease and "terrible" British food to Russian President Vladimir Putin and Germany's Chancellor Gerhard Schroeder.
The French president, who was due to join Mr Blair at the G8 summit in Scotland later today, only spent a day in Singapore while the British PM was there for three days.
Tony Blair hailed London's victory in the battle to stage the 2012 Olympics today, saying that the city would stage a "fantastic" Games. The Prime Minister said that the effort by the bid team led by Lord Coe had been "just awesome". "We have got a great chance now to develop sport in our country and to have a fantastic Olympic Games and then to leave a legacy for the future," he told reporters in Gleneagles, where he is hosting the G8 summit.
The Princess Royal told Sky News: "If you listen to what the senior athletes said it's worth bearing in mind they were all inspired very early by watching things like the Games - the potential is enormous.She added: "They are all good bids, it was going to be close."
Sally Gunnell, Olympic gold medalist said it was a "fantastic feeling" to know London would be hosting the Games in 2012.She told Sky News: "You're going to get 15-year-olds at the moment saying I want to be at those Olympics they've got an opportunity now to take part, if not going to see it."
David Beckham, who spoke in Singapore yesterday of the prospect of the games taking place on his east London "manor", compared the capital's victory to winning the European Cup.
Lord Coe, the leader of London's Olympic bid said he was " ecstatic" about winning.
He told Sky News: "I always always knew this was going to be close, in fairness I pretty much guessed from some time out what I thought the final would be. "These are five very strong cities - Moscow, New York, Madrid, Paris, London - as sporting cities they don't get much bigger." Commenting on his feelings he said: "I feel absolutely ecstatic, we have the opportunity to do what I've always dreamed about in British sport just getting more young people into it - this is our moment really."
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies