Nils van der Poel gave Sweden its first Olympic speedskating medal since 1988, pulling off a stunning comeback to win gold in the 5,000 meters Sunday at the Beijing Games.

Van der Poel was a big favorite coming into the event as the reigning world champion, with an undefeated record in the distance events on this season's World Cup circuit.

LIVE UPDATES: BEIJING OLYMPICS

The 25-year-old lived up to the hype in the 12 1/2-lap race at the Ice Ribbon oval, turning on the speed at the end to overcome Patrick Roest of the Netherlands with an Olympic record of 6 minutes, 8.84 seconds.

Roest had skated about an hour earlier in the sixth of 10 pairs, initially breaking the Olympic mark in 6.09.31.

Then he nervously watched in the workout room as one pair after another failed to take down his time.

It looked as though van der Poel in the final group would come up short, too, as he fell 2 seconds behind Roest's pace with just three laps to go.

Then the Swede kicked it into another gear.

Beijing Olympics Speedskating Nils van der Poel

Nils van der Poel of Sweden celebrates after winning the gold medal and setting an Olympic record in the men's speedskating 5,000-meter race at the 2022 Winter Olympics, Sunday, Feb. 6, 2022, in Beijing.  (AP Photo/Ashley Landis)

He thrilled the sparse crowd by slicing into Roest's time with each stride, his progression marked in real time on the scoreboard.

Turns out, van der Poel had just enough time to claim the gold. His final lap was a scorching 28.97 — his second-fastest of the grueling event.

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

Van der Poel threw up his arms when he saw the winning time. Roest, watching the race on a video screen, let out a groan and dropped his head in disbelief, his coaches gathering around to console him.

The bronze went to Hallgeir Engebraaten of Norway in 6:09.88.

Van der Poel became the first Swedish speedskater to claim a medal since Tomas Gustafson won a pair of golds in the 5,000 and 10,000 at the Calgary Games 34 years ago.

Since then, the Swedes had not finished higher than seventh in an Olympic race.

Sven Kramer’s quest for a fourth straight speedskating gold medal in the 5,000 ended quickly.

The 35-year-old Dutchman skated in the first pair of the day and finished in 6:17.04 — more than 7 seconds off his gold medal-winning time at the Pyeongchang Games and only good enough for ninth.

Kramer was the first male skater to win the same event at three consecutive Olympics, but he’s no longer the world’s dominant long-distance performer.

Kramer plans to retire after the Beijing Games, but he still has a couple of events to go. He’ll also compete in the mass start and team pursuit.

CLICK HERE TO GET THE FOX NEWS APP

No matter what, Kramer is already assured of leaving the sport as the most decorated male speedskater in Olympic history, with nine medals over the last four Games, including four golds.

Emery Lehman and Ethan Cepuran of the United States finished 16th (6:21.80) and 17th (6:25.97), respectively.

Lehman filled in for teammate Casey Dawson, who has been stuck in the U.S. after testing positive for COVID-19 several weeks ago.

Dawson still hopes to be cleared in time to get to Beijing for next week's team pursuit