SAN FRANCISCO — The Dodgers clinched baseball’s final playoff berth and gave themselves a chance to still win the NL West, getting a go-ahead triple from Manny Machado in the eighth inning Saturday and beating the Giants 10-6.

The defending NL champions locked up their sixth straight trip to the postseason, assuring at least a spot in the wild-card game.

The Dodgers moved into a first-place tie in the West with the Rockies, who fell at home to the Nationals 12-2 later Saturday. The regular season is scheduled to end Sunday — if the Dodgers and Rockies finish even, there will be a one-game tiebreaker for the West title Monday at Dodger Stadium.

After the final out Saturday, the Dodgers exited their dugout and high-fived in a tame celebration. Manager Dave Roberts waved to hundreds of fans in the outfield bleachers.

The Dodgers’ win eliminated the Cardinals from playoff contention.

Machado, the star infielder acquired from the Orioles during the All-Star break, hit a two-out triple off Mark Melancon (1-4) for a 6-5 lead. Max Muncy added a two-run double during a four-run ninth, much to the delight of all the Dodger Blue in the rival’s ballpark.

Alex Wood (9-7) pitched the seventh for the win and Kenley Jansen closed it out.

Clayton Kershaw allowed eight hits and five runs over five innings and had a two-run single in the fourth for his first career RBIs in 24 games at AT&T Park.

Kershaw had two stints on the disabled list this year, made just 26 starts and failed to beat the Giants in four 2018 outings. He missed double-digit wins for the first time since going 8-8 in 2009.