KRASNAYA POLYANA, Russia — To prepare for her first Olympics, Mikaela Shiffrin envisioned every scenario possible. Winning, falling short of a medal, crashing. Prior to the competition, the 18-year-old American said she had been to the Winter Games “before, in my head.”

While everybody else saw it as her first Olympics, Shiffrin felt as though it was her thousandth.

Still, all the visualization could not compare with what it felt like for real, not when Shiffrin became the youngest Olympic women’s slalom champion in history Friday, and did so with a dramatic nighttime run.

Shiffrin recovered from what she called a “terrifying” bobble midway through her second run to claim the gold in 1:44:54. Despite that bobble, which caused her left ski to fly out from underneath her and elicited a gasp from the crowd, she finished .53 seconds ahead.

With her history-making performance, Shiffrin added to the US medal count, which stands at an Olympic-leading 27 with two days of competition remaining. Host Russia is one behind. The teenage skier brought the US gold-medal total to nine, including four collected by women and one by ice dance pair Meryl Davis and Charlie White. In Alpine skiing, the United States has five medals — two gold, one silver, and two bronze. Only traditional power Austria has more medals (seven) in Alpine skiing.

When asked how reality compared with what ran through her head a thousand times, Shiffrin said, “I’m not really sure that this is reality right now.

“I did envision this moment so many times. Then I get to the chair-lift ride to start the second run, I started tearing up. I was like, ‘This actually might happen. And I don’t know what to think if it does.’ Then it did happen and I don’t know what to think.

“You can visualize this in your head and you can mentally prepare and you can make the moment happen and create your miracle. But when it does happen, it’s hard to put into words how incredible it is.”

Standing on the podium between two of her skiing idols from Austria — silver medalist Marlies Schild and bronze medalist Katrin Zettel — Shiffrin put her hands to her knit cap as a look of disbelief lit up her face. It was the face of an awed teenager. After a day on which she exhibited the poise under pressure of a veteran, it was a reminder of how quickly she has climbed the racing ranks.

The victory makes Shiffrin the first American winner in women’s slalom since Barbara Ann Cochran, the Vermonter who took the title at the 1972 Sapporo Games. She is the first American to take slalom gold since Phil Mahre in 1984. And she is the fifth-youngest female gold medalist in Alpine skiing.

Translation: The present and future of US ski racing is Shiffrin, a precocious talent who could someday surpass the achievements of Lindsey Vonn, an Olympic downhill gold medalist and 17-time World Cup title winner (four overall, 13 discipline titles). The next question is: How long until she tackles the speed events and finds success there?

“I first met her when she was 16, and I realized right away that she is one of a kind,” said US Ski Team technical event coach Roland Pfeifer. “She wants to know everything about skiing, and the way she trains, the volume she trains, she probably is 25 already.

“So it’s kind of normal that she’s going to ski the way she skis because she trains so much. She really thinks 24/7 about skiing. Gifted the way she is and working hard the way she does, [this] is the result.”

But that doesn’t mean her final run was without drama.

On the flatter portion in the middle of the course, Shiffrin lost her balance on softer snow and her left ski lost contact with the ground. She had made a similar mistake in the last World Cup race before the Olympics and finished seventh.

But with equal parts athleticism and willpower, Shiffrin relied on her quick feet, regained her balance, and made a remarkable recovery.

“That was pretty terrifying for me,” said Shiffrin, who is from Eagle-Vail, Colo., but spent part of her childhood living in New Hampshire and attended Burke Mountain Academy in Vermont. “There I was. I’m like, ‘All right, I’m going to just go win my first medal.’ Then in the middle of the run, I’m like, ‘Guess not.’ Then I was like, ‘No, don’t do that. Do not give up. You see this through.’ ”

After she sped across the finish line, she was hesitant to look at the scoreboard.

“I was a little bit scared to look at it,” said Shiffrin, who developed a head cold after Tuesday’s rain-soaked giant slalom, her first Olympic event, in which she finished fifth. “I was like, ‘Oh, I gave it away. I know it.’

“Then I’m always in this little frenzy of finding it. So, I’m looking around frantically like, ‘Where am I?’ I finally saw it and I was like, ‘Oh, phew, OK, you got that one done.’ ”

Shiffrin got it done, in part, because she built a sizable cushion in her first run Friday afternoon. With turns that seemed effortless and an upper body that appeared almost motionless, she finished in 52.62 seconds, reaching the halfway point of the competition with a 0.49-second advantage.

Even with a good gap on the field, Shiffrin played it cool in the finish area.

“I’m not really worried about the lead right now,” she said. “Actually, five-tenths isn’t even that much. It’s a two-run race.”

Shiffrin didn’t see anything particularly tricky about the Rosa Khutor course, though the gates were set tighter than what she usually sees on the World Cup circuit. Typically, gates on a slalom course are spaced 10-11 meters apart, but on Olympic runs, they are 9-10 meters apart. While Shiffrin said it was “not actually that big of a deal,” she clearly made a mental note of it and adjusted her rhythm down the slope.

Yet another example of the attention to detail and poise under pressure that has made Shiffrin a ski racing prodigy.

Shiffrin entered the slalom as the gold-medal favorite. She won last year’s world championship in Schladming, Austria. She also claimed the 2012-13 World Cup season title and she currently tops this season’s World Cup rankings.

“I always dream of the best-case scenario and accept it if it doesn’t happen, but I’m really glad that it did today,” said Shiffrin. “I’ve just got to keep going.

“It’s an amazing feeling to win an Olympic gold. It’s going to be something that I chalk up as one of my favorite experiences for the rest of my life, but my life is not over yet.”

Despite her almost catastrophic mistake, Shiffrin enjoyed making her second run under the lights. Considering that her first win on the World Cup circuit was a night slalom in December 2012, the setting may have been a good omen. Because under the nighttime lights and the intense Winter Games spotlight, she looked like the seasoned Olympic veteran she was in her head.