SAN FRANCISCO -- San Francisco Giants manager Bruce Bochy was out of options after emptying his bench of position players three innings earlier and with the potential winning run at third base in the 12th inning. Then, he turned to his best hitting pitcher.
It worked perfectly.
The Giants recorded their 10th walk-off win of the season, and won for just the fifth time in 22 games.
"It's tough this time of year to come and compete and play as hard as you ordinarily would but this is the time you have to look yourself in the mirror and go out there and do your job, earn your paycheck," Bumgarner said "As soon as we ran out of guys, I got my cleats and my jersey on."
After Hernandez tripled off Rowan Wick (0-1), Bochy called for Bumgarner.
Bumgarner took a called strike and 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 three RBI in 41 at-bats for a .146 average. He has a career batting average of .182.
"He smoked it, didn't he?" Bochy said.
Mark Melancon (1-3) retired six batters to earn win.
At 63-95, the Padres are assured of their worst record since 2008, when they finished 63-99.
San Diego stranded a runner at third in the 11th and at first and third in the 12th. The Padres also matched their season high of three errors, two by shortstop Javy Guerra.
"It's a tough one for us," San Diego manager Andy Green said. "We gave away some runs on the defensive side and it's tough. We've played relatively clean defense for a while and we didn't really do that today."
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: Panik didn't start but entered as a pinch-hitter in the seventh. 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.
More AP MLB:�https://apnews.com/tag/MLB�and�https://twitter.com/AP-Sports
How the new dead ball is faking out players, fans and even cameramen
On the field and in the stands, how players and others react to MLB's newly juiceless baseballs off the bat tells a story.
Justin Verlander looks to close out New York Yankees in ALCS
Justin Verlander is one of the best close-out pitchers of all time, but he stumbled in his last opportunity. That can't happen again, right?
Where things stand as Chicago Cubs zero in on next manager
Indications are that Chicago is near making a choice to replace Joe Maddon, with former Cubs catcher David Ross the front-runner.
MLB playoffs daily: Houston Astros have World Series in their sight
Houston has the Yankees on the ropes, with Justin Verlander lined up to deal the knockout blow in Game 5.
Astros turn to Verlander to clinch ALCS vs. Yanks
Last season, the Houston Astros were unable to get back to the World Series because after winning the first game of the American League Championship Series, they lost the next four to the eventual champion Boston Red Sox.
Yankees playing their worst baseball at the worst possible time
Of course, the Astros are great. But come on, Yankees. Four errors? No key hits? Few signs of life? You're better than that.