With its 15-year-old figure skating darling falling for a second time in two nights and its star-studded hockey team sent packing the previous day, Russia’s sporting pride was salvaged in epic fashion Thursday by a teenager few in the country had heard of when the 2014 Sochi Olympics dawned.

Adelina Sotnikova, a 17-year-old eyed as an understudy to revered skating mite Julia Lipnitskaia, shattered previous personal-best marks to win Russia’s first women’s figure skating gold at the Winter Games. And she did so by more than five points over defending Olympic and world champion Kim Yu-na of South Korea, the last skater to compete in Thursday’s decisive free skate.

“I gave a great gift to my country,” Sotnikova said as the Olympics’ host nation basked in her reflected glory.

Within hours, the world of Russia Twitter offered rounds of virtual applause for Sotnikova. Her name quickly took over the top trending spots on Twitter in Moscow (in Russian) on Thursday evening: No. 1: #Sotnikova, No. 2: #figureskating; No. 3: #AdelinaSotnikova; No. 4: #Sochi2014.

Opposition leader Alexei Navalny jumped in to offer his congratulations.

And still the tweets came, like the bouquets of flowers that earlier had been thrown on the ice: “Your whole country is proud of you,” “Beauty saved the world, and brought us the gold!” “Our skaters are angels I’m proud of Julia and Adelina!”

Kim, 23, and Sotnikova entered the final phase of the women’s competition in a virtual tie, with Kim leading by less than 0.3 points.

NBC Figure Skating analysts and former Olympians Johnny Weir and Tara Lipinksi talk about their experience in Russia and the sport of figure skating. (Associated Press)

Competing 21st among 24, Sotnikova staged a more difficult free skate, with seven triple jumps. And she attacked it bravely, fighting on after a bobble during a three-jump combination, then was overcome with tears of joy when showered with wild applause.

The marks (149.95) were the best of her young career and vaulted her into the lead. But it was far from certain that lead would stand once Kim, the evening’s final skater, competed.

Kim had never finished lower than third her entire career. Despite scarcely competing last fall, sidelined by a foot injury, she returned to the world stage for Sochi, which she had announced would be the final competition of her career. After a breathtaking short program, she was poised to become the first woman since Germany’s Katarina Witt to win back-to-back Olympic gold medals.

Kim’s free skate wasn’t as technically demanding as Sotnikova’s, with one fewer triple jump, so she surrendered 3.94 points in terms of its “base value” from the start. But Kim’s performance was so exquisite, so poetically rendered, that she seemed assured of defending her title.

When Kim’s score (144.19) was posted and it became clear it wasn’t enough to overtake the Russian, Sotnikova and her coach were stunned.

“When I had performed all the elements, I knew I would be on the podium but not which medal,” Sotnikova said afterward. “When I saw I had won on the technical elements, I didn’t believe my eyes.”

In a news conference that followed, Kim didn’t question the score.

“The score is given by the judges,” Kim said. “I’m not in the right position to comment on it. And my words can change nothing.”

Judges gave Sotnikova technical marks that were 5.85 points higher than Kim’s, with the extra triple jump explaining part of that differential.

What perplexed several figure skating insiders was the razor-thin difference in the artistic marks, known as “component marks.” Kim edged Sotnikova by 0.09 points.

“It’s really hard to quantify the artistic side of skating,” former U.S. Olympic figure skating coach Audrey Weisiger said in a telephone interview. “But I would say that most people watching, if you take all the jumping out of the programs and just watch the artistry, Kim should have been further ahead than she was. You don’t have to be a trained figure skating coach to recognize when something is more pleasing.”

Many in the stands at the 12,000-seat Iceberg Skating Palace were stunned, too, along with many watching on TV, convinced Kim had won the day.

Alexandria’s Ashley Wagner, who finished seventh in her Olympic debut, described herself as “speechless.”

“To be completely honest, this sport needs fans; this sport needs people who want to watch it,” said Wagner, 22, a West Potomac graduate. “People do not want to watch a sport where they see someone skate lights out, and they can’t depend on that person to be the one who pulls through.”

Taking the bronze medal was Italy’s Carolina Kostner, 27, who enchanted judges and the crowd with her performance to Ravel’s “Bolero.”

The 18-year-old U.S. figure skating champion, now competing in Sochi, says being on the ice is all about breathing and bending your knees. (Lee Powell/The Washington Post)

Gracie Gold, 18, was the top American, finished fourth after falling on a triple flip in an otherwise sparkling free skate. And 15-year-old Polina Edmunds, who also tumbled on a triple flip, finished ninth.

The waiflike Lipnitskaia, who stood fifth after falling during her short program, got off to a strong start to her free skate to music from “Schindler’s List,” portraying the girl in a red coat spied amid the chaos of the Krakow ghetto. But she stepped out of a triple loop and fell on the triple Salchow that came late in the performance.

Wagner, in sixth after her short program, faced long odds of finishing atop the medal podium. But in a sparkling yellow gown, and competing a reworked program for the first time, she hit all but the back end of her triple flip-triple toe combination yet stayed upright and poured herself into telling the tale of the temptress in “Samson and Delilah.

“I stepped out on the ice, and I skated for myself — mostly to prove to myself that I belong here,” Wagner said. “This is the best I’ve skated this entire season.”

The outcome likely will rekindle debate over whether judges’ individual marks should remain anonymous.

U.S. Figure Skating has presented a proposal to figure skating’s international governing board calling for an end to anonymous judging, which was introduced in hopes that judges would feel more free to voice their opinions.

Many believe it hasn’t worked.

“It makes our sport sort of a joke when we’re protecting the judges,” Weisiger lamented. “What kind of sport is this when judges are afraid to voice their honest opinion?”

The venerable coach John Nicks agrees.

“It’s very obvious: It should be transparent,” Nicks said in a telephone interview. “There are many arguments for it to be transparent, and I don’t know of any arguments that would be against it. It’s simple: You should stand up and accept responsibility for your actions, whatever job you’re doing and whatever sport you’re involved in. A judge’s marks should be known.”

Kathy Lally contributed to this report from Sochi.