SAN FRANCISCO (AP) - Pitcher Madison Bumgarner had the first game-ending hit of his career, a pinch-hit single in the 12th inning that drove in Gorkys Hernandez, and lifted the San Francisco Giants to a 5-4 victory over the San Diego Padres on Tuesday night.
Hunter Pence homered and scored three times in what was likely one of his final games with San Francisco. Gregor Blanco had a two-run single and Evan Longoria added an RBI double.
The Giants recorded their 10th walk-off win of the season, and won for just the fifth time in 22 games.
Freddy Galvis had four hits and a walk, continuing his offensive surge for San Diego. Eric Hosmer added a two-run single.
At 63-95, the Padres are assured of their worst record since 2008, when they finished 63-99.
San Francisco blew a 4-3 lead in the ninth when Wil Myers doubled and scored off Tony Watson. But the Giants rallied in the 12th after going hitless the previous four innings.
After Hernandez tripled off Rowan Wick (0-1), and without a position player left on his bench, Giants manager Bruce Bochy turned to his best hitting pitcher.
Bumgarner took a called strike, then lined a sharp single past third baseman Myers to drive in the winning run. It was Bumgarner's fourth career pinch-hit and first since July 31, 2016. He has six hits and 3 RBIs in 41 at-bats for a .146 average. He has a career batting average of .182.
Mark Melancon (1-3) retired six batters to earn win.
San Diego stranded a runner at third in the 11th and at first and third in the 12th.
Pence, who reached on an error and scored in the first, homered off Robbie Erlin in the fourth and received a standing ovation from the announced crowd of 36,063.
The 35-year-old outfielder also singled and scored the go-ahead run on Gregor Blanco's double off Robert Stock (1-2) in the seventh. Blanco had been 5-for-32 with runners in scoring position.
Recognized as one of the driving forces behind the Giants' World Series titles in 2012 and 2014, Pence is scheduled to become a free agent in the offseason.
Giants: 2B Joe Panik was given the day off. Catcher Nick Hundley was hit in the back of the head on a follow-through swing by Austin Hedges in the 12th inning, but remained in the game.
San Diego RHP Luis Perdomo (1-6, 7.56) makes his first start since July 27 in the series finale Wednesday as part of manager Andy Green's plan to bullpen the game. Perdomo has made two relief appearances after being recalled from the minors earlier this month. RHP Casey Kelly (0-2, 2.04) makes his third start for the Giants and first against his former team. Kelly pitched for the Padres in 2012 and 2015.
(Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.)