LOS ANGELES — Keibert Ruiz celebrated his ninth-inning homer with extra chest-thumping zeal, leaving no doubt that a big day at the plate in Dodger Stadium meant something special to the former Los Angeles prospect.

“Yeah, a little bit,” he said with a grin.

Ruiz was one of several Nationals who made sure they headed home from an eventful road trip Wednesday with celebrations and positive feelings.

Luis García hit a tiebreaking three-run homer in the eighth inning, Ruiz added two of Washington’s season-high five homers, and the Nationals avoided a series sweep with a 10-6 victory over the Dodgers.

The Baltimore Banner thanks its sponsors. Become one.

Washington scored five runs in the final two innings after the Dodgers rallied to even it 5-5. García had been in a 2-for-22 slump since his six-hit game against Kansas City last week, but he connected for a two-out, two-strike shot down the right-field line off Brusdar Graterol (2-2).

“Very happy and excited to finish the road trip this way,” García said through a translator. “Baseball has its ups and downs, and you have to learn to deal with them. I never put my head down, and I just kept working.”

Ruiz, who got traded to Washington in a package for Max Scherzer and Trea Turner in 2021, homered in the second and ninth innings, giving him three in the last two games in LA.

“I respect them,” Ruiz said of the Dodgers. “They’re a really good team, good people. ... It felt really good, especially in that moment when the game is close.”

Jeimer Candelario homered and drove in three runs, and CJ Abrams also homered for the Nationals, who overcame an early three-run deficit to beat the Dodgers for only the fourth time in the last 16 meetings. Hunter Harvey pitched two innings for his third save.

The Baltimore Banner thanks its sponsors. Become one.

“They’ve got some of the better hitters in baseball, but to win the final game feels pretty good,” Nats manager Dave Martinez said. “Hopefully we figured some things out here as a club, and we come back and do it again on Friday.”

Mookie Betts hit his 40th leadoff homer and added a solo shot in the eighth for the Dodgers, who lost at home for only the second time in 15 games since late April. Will Smith added a two-run shot in the first inning, but NL-leading Los Angeles’ home record dropped to 19-8 on manager Dave Roberts’ 51st birthday.

Freddie Freeman capped his spectacular month by extending his hitting streak to 20 games while going 2-for-4 with two stolen bases. Freeman batted .400 in May and set Dodgers franchise records with 24 extra-base hits and 17 doubles.

Noah Syndergaard struggled yet again for LA, blowing two leads while allowing five runs, seven hits and two walks over five innings with just two strikeouts. The once-intimidating right-hander has a 6.54 ERA after allowing multiple runs in nine consecutive starts, not counting one appearance that lasted only one inning because of injury.

“I would give away my hypothetical first born to be the old me again,” said Syndergaard, who had Tommy John surgery in 2020.

Roberts was asked if Syndergaard will make his next start: “I don’t know. The hope is that he does, but right now I just don’t want to answer that.”