SAN FRANCISCO (AP) — Cody Bellinger hit a tiebreaking single in the ninth inning and prized midseason acquisition Max Scherzer came out of the bullpen for his first career save, sending the Los Angeles Dodgers past the San Francisco Giants 2-1 in a thrilling winner-take-all Game 5 on Thursday night and into the NL Championship Series.

Bellinger's big hit decided a scintillating NL Division Series between talent-laden teams with lofty win totals — the latest exciting chapter of this storied rivalry.

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

No matter, the Dodgers rushed out of their dugout to celebrate on the Giants’ home field. Meanwhile, fans threw beer cans and debris onto the diamond in disgust.

“The umpire said it was a swing, so it was a swing,” Bellinger said.

Mookie Betts had a postseason career-high four hits and will lead the next step for the defending World Series champions at Atlanta for Game 1 of the best-of-seven NLCS 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 its 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 scrutinized season.

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

Scherzer, the Game 3 loser who came over from Washington at the trade deadline, closed out a best-of-five series certain to go down among the several classics these franchises have played — right up there with the 1951 and ’62 clubs that each matched up in three-game tiebreakers for the NL pennant that the Giants won each time.

In the 24th and 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. The 107-win Giants edged the Dodgers for the NL West title on the final day, Los Angeles winding up a game back with 106 victories.

The Dodgers already won once facing elimination, topping the Cardinals last week in the wild-card game 3-1. And manager Dave 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 LA 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. “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.

Then 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 is the longest of this postseason.

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

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

Betts led off the game with a single but the Giants got out of it with an inning-ending double play and Webb faced the minimum through two.

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

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

BETTS’ BAT

Betts is only the second batter with three hits in a game against Webb this year, joining San Diego’s Eric Hosmer on April 30.

The LA right fielder also is the first player in Dodgers history with four hits in a winner-take-all postseason game.

SCULLY SAYS

Hall of Fame broadcaster Vin Scully, who retired following the 2016 season after 67 years calling Dodgers games, weighed in on the magnitude of this Game 5 matchup in the clubs’ storied histories.

“To my knowledge, tonight’s game between the (at)Dodgers and (at)SFGiants is the most important game in the history of their rivalry. With nearly identical records, and so much at stake, I believe this to be the case,” Scully posted on Twitter. “Many of you might consider the 1951 game for the NL pennant to be bigger. Perhaps, but that was more about the greatest moment with Bobby Thomson’s game-winning home run.”

Roberts was told before the game of the 93-year-old Scully’s remarks.

“Now I feel pressure, gosh darn it, man,” Roberts said with a grin.

FOSSE REMEMBERED

A moment of silence and a thoughtful big screen tribute were held for two-time All-Star catcher Ray Fosse, who died Wednesday at age 74 after a 16-year battle with cancer. He had worked earlier this season as a broadcaster across the bay for the Oakland Athletics.

___

More AP MLB: https://apnews.com/tag/MLB and https://twitter.com/AP_Sports