Pablo Sandoval homered with two outs in the 11th and the Giants beat the San Diego Padres 2-1 Friday night for their 18th victory in 22 games.
Sandoval's drive on a 1-2 pitch from Logan Allen (2-3) just cleared the wall in left field. It was his 13th. He entered as a pinch-hitter in the ninth, when he hit a leadoff double, and stayed in at third base.
"It doesn't get any bigger than that, what he did," San Francisco manager Bruce Bochy said. "It's another hard-fought game. These guys seem to like that, going overtime here."
The Giants have won six extra-inning games in their last 10 contests and seven in their past 15 since the All-Star break.
"It tells me that we have a great bullpen," said starter Jeff Samardzija, who pitched six strong innings. "To win extra-inning games, you've got to be throwing up zeros with guys that obviously aren't starters. I know our starters have pitched well to make sure we've given these guys some time off, but they've gone out there and been so efficient and so solid with their work that they've made these extra-inning games not be too taxing on them and haven't taxed our bullpen too much because they've been so good.
"We'll keep trying to eat up innings as starters, but tell you what, winning close games is some of the best things you can do for a whole season when it comes to momentum and feeling good about yourselves and being confident in those situations going forward."
The Giants have won four straight games against San Diego at Petco Park in July, part of a surprising surge that has helped them jump into the NL wild-card race.
The Padres have lost eight straight home games. They were coming off a 3-6 trip.
Mark Melancon (4-2) struck out two in a perfect 10th for the win. All-Star closer Will Smith pitched the 11th for his 25th save, getting Eric Hosmer to hit into a game-ending double play.
Giants center fielder Kevin Pillar made a nice running catch of Wil Myers' deep fly ball for the second out of the ninth.
San Diego's Austin Hedges tied the game at 1 with a home run off Jeff Samardzija into the balcony on the third level of the Western Metal Supply Co. Building in the left field corner with one out in the fifth, his eighth.
Samardzija and Padres left-hander Joey Lucchesi each pitched six strong innings. Samardzija allowed one run and four hits while striking out six and walking three. Lucchesi yielded one run and two hits while striking out eight and walking four.
"Just not a good offensive performance by us," Padres manager Andy Green said. "We've just got to put runs on the board. It's really simple. Just not enough quality at-bats today against Samarjdzija. He's a veteran pitcher whose stuff was moving quite a bit today. We didn't make the necessary adjustments and get to him."
Lucchesi retired his first six batters before walking Tyler Austin leading off the third. Austin stole second and scored on Donovan Solano's double to the center field wall.
Lucchesi got into and out of trouble in the fifth, loading the bases with no outs before retiring the side by striking out Samardzija, getting an infield fly call on Donovan Solano's popup and then inducing Brandon Belt to ground out to shortstop.
SKIPPER'S FINAL PORT CALL
This is the last trip to San Diego for Bochy, who is retiring at the end of this season, his 13th with San Francisco and 25th overall in the big leagues. He managed the Padres for 12 seasons before jumping to the Giants and winning three World Series titles between 2010 and 2014.
The Padres honored Bochy with a pregame ceremony, showing a video montage of his years playing with and managing the team. Former players Carlos Hernandez, Steve Finley, Andy Ashby and Mark Sweeney joined owner Ron Fowler in presenting Bochy with a huge bottle of wine and some saltwater fishing rods.
Bochy still has an offseason home in suburban Poway.
Giants: Rookie RHP Shaun Anderson (3-2, 4.91 ERA) is scheduled to start Saturday night. He's 1-0 with a 5.40 ERA in two career starts against San Diego.
Padres: Rookie RHP Cal Quantrill (3-2, 3.76) is scheduled to make his ninth start.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports
Giants fan snags Sandoval homer while cradling baby
Pablo Sandoval's home run in the 11th inning is caught by a Giants fan while cradling a sleeping baby.