SAN FRANCISCO — Buster Posey hit three RBI doubles, Brandon Crawford drove in three runs and had three hits, and the San Francisco Giants beat the San Diego Padres 8-0 on Friday night to ensure they won’t finish with a 100-loss season.

Joe Panik added a run-scoring double among his four hits to back Chris Stratton (4-4). The Giants needed one victory in the final series of the season to avoid their first 100-loss year since 1985.

Posey and Pablo Sandoval hit RBI doubles in the first inning and Crawford had a run-scoring single as San Francisco jumped on Jordan Lyles (1-5). He was done after 3⅔ innings.

Crawford hit a two-run single as the Giants added four more runs in the fourth, all with two outs. Posey’s third double came in the sixth.

Stratton struck out seven over 6⅔ innings and walked two, allowing seven hits. The Giants have won six of his nine starts since Aug. 5.

The Padres lost their fifth consecutive game, shut out for the second contest in a row after a 10-0 loss to the Dodgers on Wednesday. San Diego has been outscored 36-5 over its past four games.

San Diego has won all five previous series with San Francisco this season and owns a 7-0-1 series record against the Giants dating to the 2016 All-Star break.

WILLIE MAC AWARD

Hall of Famer Willie McCovey presented Nick Hundley with this year’s “Willie Mac” award, voted on by Giants players, coaches and training staff to recognize the team’s most inspirational player both on the field and in the clubhouse.

“Wow, this is pretty overwhelming to be standing here with Giants legends and mentioned in the same company as Willie McCovey,” Hundley said.

Matt Cain tipped his cap when announced among former winners, as the 2009 recipient.

TRAINER’S ROOM

Giants: Rookie OF/2B Austin Slater underwent core muscle surgery earlier this week, manager Bruce Bochy said. Slater’s recovery time is estimated to be six to eight weeks.