SAN DIEGO (AP) - Pablo Sandoval homered with two outs in the 11th inning and the San Francisco 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.
Sandoval entered as a pinch-hitter in the ninth, when he hit a leadoff double, and stayed in at third base.
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.
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 Giants manager Bruce 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.