Sochi defeated the South Korean city of Pyeongchang 51-47 in the final round of voting by the International Olympic Committee.
Fireworks boomed in the sky to celebrate Sochi's selection and Russians' feeling of confidence that their long-beleaguered land has finally overcome its troubles.
Tamara Zaporozhets, a 24-year-old curtain designer, gave the sentiment some cocky street spin: "We are the best in the whole world. Sochi rocks!"
Russia, which hosted the 1980 Moscow Games, has never held a Winter Olympics.
Two previous tries by Sochi failed. A bid for the 1998 games was withdrawn amid the economic deterioration of the last months of the Soviet Union's existence. Its try for the 2002 games didn't make the final round, due to concerns about the almost-total absence of facilities.
Sochi still must build almost everything for 2014 from scratch. But this time, bid promoters pushed that as an asset, saying the new construction would mean the Olympic movement would get its most modern games ever.
The can-do attitude was bolstered by President Vladimir Putin, whose government has undertaken a program to spend billions of dollars developing the Sochi region.
Putin capped his influential backing with an impressive appearance before the International Olympic Committee hours before the vote, making lengthy remarks in English — a language to which he usually limits himself to only a few sentences. He added some passable French, too.
"Our president is the best!" exclaimed Sochi resident Ana Malashenko after the vote announcement.
The Austrian resort of Salzburg was eliminated in the first round of the secret ballot, setting up the decisive head-to-head contest between Sochi and Pyeongchang.
Pyeongchang led the first round with 36 votes, followed by Sochi with 34 and Salzburg with 25. Sochi picked up 17 votes in the second round to secure the victory.
The result was a triumph for Putin, who put his international prestige on the line by coming to Guatemala to lobby IOC members and lead Sochi's final formal presentation to the assembly. Putin had left by the time the result was announced.
IOC president Jacques Rogge opened a sealed envelope and read the words the Russians longed to hear:
"The International Olympic Committee has the honor of announcing the 22nd Olympic Winter Games in 2014 are awarded to the city of Sochi."
Russian delegates in the hall erupted in cheers, jumped to their feet and hugged each other. They unfurled a Russian flag and chanted, "Sochi! Sochi!" Korean delegates bowed their heads, some in tears.
"It was a historic decision for all countries," Sochi bid chief Dmitry Chernychenko said. "Russia will become even more open, more democratic."
In Sochi, cheers erupted from the crowd of more than 15,000 that had gathered for a pop concert and the announcement in a main square.
"We did it all together. We won," the concert's announcer said from the stage as fireworks flashed and boomed in the sky.
People hugged and waved their hands in the air. Some appeared to have tears in their eyes.
"It is great. I've never been so happy in my life," said Marina Matveyeva, 23, who works in a bank. "It means that Russia has reached the level of Europe, and we can be proud of our country."
Russia, an Olympic power which has won 293 Winter Games medals, has never hosted the Winter Games. That was a strong point in Sochi's favor with the IOC, which likes to spread the Olympics to new host countries. Moscow hosted the 1980 Summer Games, which were hit by the U.S.-led boycott following the Soviet invasion of Afghanistan.
The Sochi bid won out over the appeals of its rivals — Salzburg, presenting itself as a safe, no-risk winter sports mecca at the heart of Europe with world-class venues already in place; and Pyeongchang, offering the potential for peace and reconciliation on the divided Korean peninsula and promoting winter sports in Asia.
Ninety-seven IOC members were eligible to vote in the first round, with 95 casting valid ballots. Members from bidding countries are ineligible to vote as long as their cities remain in contention. With Salzburg out, 100 delegates were eligible in the second round, with 98 casting valid votes.
Putin's government has pledged $12 billion to develop Sochi into a world-class winter sports complex linking the palm-lined Black Sea coast — the so-called "Russian Riviera" — to the soaring Caucasus mountains nearby.
Putin, one of the world's most powerful figures, emphasized his commitment by making a rare formal presentation in English to the IOC. He praised Sochi's natural setting, saying, "On the seashore you can enjoy a fine spring day, but up in the mountains, it's winter ... a real snow is guaranteed."
Although the site would have to be built largely from scratch, Putin assured, "We guarantee the Olympic cluster in Sochi will be completed on time."
"No traffic jams, I promise," he said with a smile.
Noting that athletes would have a short walk to their venues, Putin said, "Five minutes' walking distance, not bad."
It was the second straight first-round defeat for Salzburg, which also mounted a failed bid for the 2010 Winter Games, which went to Vancouver, British Columbia.
The Austrians were squeezed out by the political and economic might of the Russian and Korean bids.
Despite the festivities in Sochi, some Russians were dismayed, particularly environmentalists who say the massive construction of sports facilities in the mountains and along the Black Sea coast will cause severe damage to delicate ecosystems.
"This will pose a threat to those valuable natural resources for which we are fighting. It's absolutely inadmissible," Mikhail Kreindlin of Greenpeace Russia told The Associated Press.