AP photo by John Hefti / The Los Angeles Dodgers celebrate after beating the host San Francisco Giants 2-1 on Thursday night to win the deciding Game 5 of their NL Division Series.

SAN FRANCISCO — Cody Bellinger pointed at the dugout and pounded his chest after delivering the biggest hit of the season for the reigning World Series champions.

Of course, it took until the ninth inning of the 24th and final meeting this year to finally separate the Los Angeles Dodgers and the San Francisco Giants.

It couldn't have been any closer.

Bellinger hit a tiebreaking single in the top of the ninth, and prized midseason acquisition Max Scherzer came out of the bullpen in the bottom half for the first save of his MLB career, sending the Dodgers past the Giants 2-1 Thursday night in a thrilling winner-take-all Game 5 of their National League Division Series.

Bellinger's line drive up the middle decided a scintillating NLDS between teams that had a combined 213 regular-season victories between them this year — the Giants' 107 wins edged the Dodgers' 106 for the NL West Division title on the final day — adding a new chapter to this storied, century-old rivalry.

"We poured everything we could into this series, and it took everything we had to beat these guys," Dodgers manager Dave Roberts said.

And the dramatic finish came with a controversial call: With a runner on, Scherzer struck out Wilmer Flores on a checked swing. First base umpire Gabe Morales called Flores out on appeal — but on television replays, it certainly didn't appear he swung.

"The umpire said it was a swing, so it was a swing," Bellinger said.

The Dodgers rushed out of their dugout to celebrate on the Giants' home field. Fans began throwing beer cans and debris onto Oracle Park's diamond in disgust.

"Super tough. Obviously, you don't want a game to end that way," San Francisco manager Gabe Kapler said. "There's no need to be angry about that. I just think it's a disappointing way to end. There are other reasons we didn't win today's baseball game, so that was just the last call of the game."

Mookie Betts had a postseason career-high four hits for the wild-card Dodgers, who advance to the NL Championship Series against the Atlanta Braves, who wrapped up their NLDS with the Milwaukee Brewers by winning Game 4 on Tuesday night. Atlanta, the four-time reigning NL East champion, will have home-field advantage as the higher seed and will host Game 1 on Saturday night.

Los Angeles came back from a 3-1 series deficit to beat the Braves in last year's NLCS, taking Game 7 by a 4-3 score on the way to the franchise's first title since 1988.

"It's going to be another good one. It's not going to be easy," Bellinger said. "We played each other a few times the last few years. So we kind of know what each other's got, and really looking forward to it."

Camilo Doval plunked Justin Turner with one out in the ninth and Gavin Lux then singled before Bellinger delivered his most meaningful hit in a difficult season.

Before the big single, he was 5-for-62 (.080) against the Giants in 2021.

"You really do want to be in that moment," Bellinger said.

Scherzer, the Game 3 starter (and loser by a 1-0 score) who came over from the Washington Nationals at the trade deadline in late July, pitched a hitless ninth on two days' rest to close out a series certain to go down among the several classics these franchises have played — right up there with the 1951 and 1962 editions that matched up in three-game tiebreakers for the NL pennant, with the Giants winning each time.

"That was crazy. That's nuts," Scherzer said. "So to be in that moment, with everything on the line, with the way we've been playing this whole series, to get the ball in that situation, man, that was a rush."

In the final meeting between these so evenly matched rivals who knew everything about each other by this stage, it was only fitting they split at 12 apiece. Both teams went into this game with 109 wins, including the playoffs.

"Best record in all of baseball, and it was just great every time we played those guys, just bringing that rivalry back to life, really playing for relevance," Roberts said.

The Dodgers already won once facing elimination, topping the St. Louis Cardinals last week in the wild-card game 3-1. And Roberts' bold Game 5 gamble paid off: 20-game winner Julio Urías pitched out of the bullpen instead of starting as originally planned. Urías entered in the third inning and gave his team four innings of relief with five strikeouts.

"I think that you can't do a job for fear of failure or potential criticism," Roberts explained before the game. "I think that you have to do your job given whatever you feel is the best way to win the game."

Betts had the Dodgers' initial three hits with singles at the top of the lineup before Corey Seager's RBI double in the sixth as the Dodgers finally got to Game 1 winner Logan Webb. Darin Ruf's first hit of the series for San Francisco after starting 0-for-9 was a tying home run in the bottom half. The 452-foot drive was the longest of this postseason.

Webb was done after seven more brilliant innings, allowing one run on four hits, striking out seven batters and walking one as he once more delighted a sellout crowd of 42,275 with their swirling orange rally towels and those deafening "Beat L.A.!" chants.

The 24-year-old right-hander and two relievers shut out the Dodgers 4-0 in San Francisco last Friday, and Webb's Sierra Elementary School to the north in Rocklin held a day in his honor this week.

Right-handed reliever Corey Knebel opened for the Dodgers and gave up Buster Posey's two-out double in the first, then pumped his fist after striking out Brandon Crawford in a seven-pitch at-bat.

The Dodgers made all the adjustments and winning moves this time.

"Sometimes there's things that you can't really explain. It's kind of like that 'it' thing," Betts said. "I feel like we have it."