It got scary for a while, but the United States men’s basketball team can exhale.

After trailing by as many as 17, the United States pulled off a miraculous fourth-quarter comeback to advance to its fourth straight gold medal game, beating Serbia, 95-91.

The U.S. trailed by 13 entering the fourth and was on the the brink of a huge upset, but it quickly cut the deficit to five with just over seven minutes to go. 

CLICK HERE FOR MORE SPORTS COVERAGE ON FOXNEWS.COM

LeBron and Steph

Lebron James, left, and Stephen Curry of the U.S. celebrate after their team's win against Serbia in the men's basketball semifinals on day 13 of the Olympic Games Paris 2024 at Bercy Arena Aug. 8, 2024, in Paris. (Gregory Shamus/Getty Images)

Then, the U.S. took over. After both teams exchanged baskets, back-to-back buckets by Joel Embiid brought the United States back to within two with just over four minutes to go. And a tough layup by LeBron James knotted it at 84 with 3:39 to go.

Serbia regained the lead, but Stephen Curry dropped his ninth three-pointer to put the U.S. up one. James then made a reverse layup to make it a three-point USA lead, and Curry matched it with his own, going coast-to-coast to put the Americans up 91-86 with 1:41 to go. The game turned on a 14-2 run by the Americans.

Steph Curry in Olympics

Stephen Curry of the United States celebrates after his team's victory against Serbia at the Olympic Games Paris 2024 at Bercy Arena Aug. 8, 2024, in Paris. (Ezra Shaw/Getty Images)

Up by two with 8.2 seconds to go, Curry, fittingly, knocked down a pair of free throws to ice it. The U.S. outscored Serbia 32-15 in the fourth quarter.

"Gotta get it the hard way," James told the NBC broadcast after the game. "Kudos to Serbia, but we came through."

Curry's 36 points were one point shy of tying Carmelo Anthony's American record in the Olympics. James recorded his second triple-double in the Olympics, finishing with 16 points, 12 rebounds and 10 assists, and Embiid added 19 points.

LeBron and Steph celebrate

Lebron James, left, and Steph Curry of the United States react after defeating Serbia on day 13 of the Olympic Games Paris 2024 at Bercy Arena Aug. 8, 2024, in Paris.  (Gregory Shamus/Getty Images)

CLICK HERE TO GET THE FOX NEWS APP

The Americans will face host country France in the gold medal game, a rematch of the gold medal contest three years ago.

Follow Fox News Digital’s sports coverage on X, and subscribe to the Fox News Sports Huddle newsletter.