LOS ANGELES — Howie Kendrick hit a tiebreaking grand slam off Joe Kelly in the 10th inning and the Nationals, boosted by a stunning rally against Clayton Kershaw, beat the Dodgers 7-3 Wednesday night and advanced to the NL Championship Series against St. Louis.

Anthony Rendon and Juan Soto homered on consecutive pitches to overcome a 3-1 deficit in the eighth against Kershaw, a three-time Cy Young Award winner. Soto had started the comeback from a 3-0 hole with an RBI single in the sixth off starter Walker Buehler, then hit a 449-foot drive of Kershaw.

Adam Eaton walked against Kelly leading off the 10th, Rendon doubled on a drive that lodged in the left-field wall and Soto was intentionally walked.

Kendrick, who was 4 for 19 with one RBI in the series, fouled off a pitch and then hit a 97 mph fastball over the wall in dead center for his second career slam. The other was a game-ending, 11th-inning drive against San Francisco in August 2017. Center fielder Cody Bellinger chased the ball all the way to the wall, putting his arms up against the fence as he ran out of room.

“It was electric. Probably the best moment of my career,” said the 36-year-old Kendrick, a 14-year big league veteran who played for the Dodgers and Los Angeles Angels. “We never gave up. The city had faith in us. The fans had faith in us. We believed in ourselves, everybody came through for us.”

Dodgers fans started exiting as the bases emptied.

The wild-card Nationals open the NLCS at the Cardinals on Friday night. Washington overcame a 19-31 start, finished 93-69 and then rallied from a 3-0, eighth-inning deficit to beat Milwaukee 4-3 in the NL wild-card game and bounced back from down 2-1 in the best-of-five series against the Dodgers.

“Oh, man, keep fighting,” Rendon said. “I think that’s the story of maybe this organization.”

The seven-time defending NL West champion Dodgers, who led the NL with 106 wins, remain without a World Series title since 1988.

“Disappointing is probably an understatement,” manager Dave Roberts said.

Daniel Hudson got the win, retiring Will Smith on a drive to the right field warning track with one on and one out in the ninth, then getting Chris Taylor on a liner to center.

Sean Doolittle pitched a perfect 10th for the Nationals, ending a streak of three straight NLCS appearances by the Dodgers.

The Nationals/Montreal Expos franchise won a postseason series for only the second time, the first since the Expos beat Philadelphia in a 1981 Division Series caused by the midseason players’ strike.

“I’m really excited for the boys in that clubhouse that fought all year,” manager Dave Martinez said.

Kershaw sat on the bench after the home runs, looking forlorn, bowing his head and holding it with his hands.

“It’s a terrible feeling,” Kershaw said.

The left-hander had replaced Buehler with two on and two outs in the seventh, and struck out Eaton on three pitches. Roberts didn’t second-guess his decision to stay with Kershaw in the eighth.

“He’s probably the best pitcher of our generation,” Roberts said. “It just didn’t work out. There’s always going to be second-guessing. I’ll take my chances any day on Clayton.”

There was a scary moment when Buehler hit Suzuki in the left wrist and the ball shot up and knocked off his helmet as the ballpark went silent. Suzuki fell to the ground, grabbing his face. He walked off his under his own power and was replaced by Yan Gomes, who moved behind the plate in the bottom half.

Stephen Strasburg fell behind 2-0 after eight pitches. Joc Pederson doubled on a drive that went through an opening in the left-field wall — the crowd saw it land in the seats and thought it was a home run — but he was awarded the double after a video review. Muncy, who had been 0 for 12 against Strasburg, drove a fastball over the center-field wall.

Kiké Hernández homered on Strasburg’s second pitch of the second inning, another fastball, for a 3-0 lead.

Strasburg gave up three runs and six hits in six innings, struck out seven and walked one.

Buehler allowed one run and four hits in 6²/₃ innings before Kershaw came in.