Canada claimed the last, most coveted title of the Games by sweeping aside Sweden 3-0 to retain their men's ice hockey crown, but two more victories for Russia gave them an unassailable lead with 13 golds to Norway's 11.
Sweden's misery was compounded by news that forward Nicklas Backstrom had failed a doping test.
Team officials were furious at the International Olympic Committee (IOC) because they were only told two hours before the game. The team doctor said the stimulant was contained in a pill the athlete had taken for many years to treat a sinus condition.
"That was one of the worst games we've ever seen, not because of the outcome and the way the team played, but because Nicklas couldn't compete in the game," said Swedish team manager Tommy Boustedt.
"This is one of the toughest days for me and Swedish hockey, and all because of the IOC."
One top Swedish official accused the IOC of putting politics ahead of sport and jeopardising the future participation of National Hockey League players at the Olympics.
On a happier note, at the Sanki Sliding Centre, Alexander Zubkov added the four-man bobsleigh crown to his two-man title, while in the cross-country, Alexander Legkov grabbed the 50 km race in a Russian medals sweep.
Those wins ensured Russia was the most successful nation at the Games, emulating the Canadians who topped the rankings on home turf four years earlier.
"People kept asking me whether I believed Russia could do as well as Canada did in Vancouver ... and I didn't believe it," 30-year-old Legkov said.
"Now this is our pride, it's wonderful. What could be better than ending the Olympics with a gold medal and helping Russia top the medal table"
Underlining the sense of national pride, a packed Fisht Stadium erupted in cheers as the Russian team marched past during the athletes' parade at the closing ceremony.
Organisers will be delighted that athletic achievement has gone hand-in-hand with a generally well-run Games, so far untouched by violence at the hands of Islamist militants opposed to President Vladimir Putin and his pet project.
Voices of dissent over Russia's human rights record, particularly regarding legislation that critics say discriminates against gays, have occasionally crashed the party, but attention has largely focused on sport.
RUSSIA PROVES CRITICS WRONG-BACH
IOC President Thomas Bach said the Russian hosts had proved their critics wrong.
"Tonight we can say: Russia delivered all what it had promised," he told 40,000 people at the closing ceremony and millions more watching on television.
"What took decades in other parts of the world was achieved here in Sochi in just seven years."
Addressing the army of volunteers who helped guide athletes, reporters and visitors to their destinations, he added:
"Through you, everybody with an open mind could see the face of a new Russia: efficient and friendly, patriotic and open to the world. We arrived with great respect for the rich and varied history of Russia. We leave as friends of the Russian people."
Bach then formally declared the Sochi Games closed.
The Olympics had more than 2,800 athletes from 88 countries - both records - and featured 12 new events to attract younger fans and more broadcasters than ever before.
However, the Games have also seen six doping cases, five more than at the 2010 Vancouver Olympics.
Early on Sunday Austrian cross-country skier Johannes Duerr, who placed eighth in the skiathlon, tested positive for performance-boosting EPO and was excluded from the Games, according to the Austrian Olympic Committee.
"There's nothing left for me than to apologise to everyone. To my family, my wife," Duerr told Austrian TV ORF at the airport as he was leaving.
Bach said the number of cases proved that the system of testing athletes was working.
"The number of cases for me is not really relevant. What is important is that we see that the system works," he said, addressing reporters hours before the closing ceremony.
The show was staged at the Fisht Stadium, one of several gleaming arenas built in Sochi that helped push the price tag for Russia's first Winter Games to an estimated $51 billion, a record for any Olympics.
Only time will tell if the project, on which Putin has staked his prestige, was worth it, as Russia faces the formidable challenge of turning Sochi and the surrounding areas into a year-round sports and entertainment hub.
Bach said Sochi had undergone an "amazing transformation" from somewhere that looked more like a "Stalinist-style sanatorium city" in the mid-1990s to an Olympic host city with state-of-the-art venues.
"It was terrible then. Seeing it 20 years after this transformation is amazing."
For now Russian officials are basking in the glory of an event they believe helped them build bridges with the West, with which Moscow has had uneasy relations under Putin.
"The friendly faces, the warm Sochi sun and the glare of the Olympic gold have broken the ice of scepticism towards the new Russia," Deputy Prime Minister Dmitry Kozak, also Putin's Olympics organiser, said at the weekend.
The medals tally was an unexpected bonus after Russia mustered just three golds in Vancouver four years ago to place 11th in the rankings.
The only regret for Russian fans was that the men's ice hockey team progressed no further than the quarter-finals.
Victory gave Canada a sweep of the ice hockey gold medals for a second consecutive Olympics. The women stormed back from 2-0 down in the last four minutes against the United States to break American hearts on Thursday.
The world's gaze then turned to the final act of the Feb. 7-23 Games, the closing ceremony, which painted Russia in far softer colours than the muscular, assertive opening spectacle.
The show's producers deliberately replicated the embarrassing technical hitch from the opening ceremony, when one of five Olympic rings failed to open.
In similar fashion, while dancers in shimmering silver tops formed four perfect rings, one group remained in a tight formation, and only opened to complete the symbol when spectators had cheered the joke loudly.
The sense of national pride at the home team's achievements was palpable as huge roars erupted for the Russian team as they paraded past the crowds.
"Well done!" chanted tens of thousands of Russians as Legkov, Maxim Vylegzhanin and Ilia Chernousov received their gold, silver and bronze medals won in the Caucasus Mountains high above Sochi earlier in the day.
After a rousing rendition of the national anthem by a choir of 1,000 children, the ceremony took viewers on a journey through Russia's rich heritage of visual arts, music, literature and dance.
A deafening volley of fireworks from the stadium's rooftop lit up the sky, and the Olympics were over.