SAN FRANCISCO -- A timely hit by Evan Longoria and a gutsy decision by third base coach Ron Wotus provided just enough momentum for the San Francisco Giants to get past another round of missed opportunities at the plate.
It also helped manager Bruce Bochy's club overcome a wacky play when the Giants failed to make the final out of the fifth inning three times on a ball that never left the infield.
Longoria hit a go-ahead, two-run double in the seventh inning and made a stellar defensive play in the ninth, and the Giants rallied to beat the San Diego Padres 6-5 on Tuesday night.
"What a huge hit," Bochy said. "That's what we've been looking for. If you look at the last three games, even earlier in this game, we had trouble getting that big hit. We needed some help at that point and Longo delivered in a big way. Great game, coming off a couple tough ones."
The Giants entered the day with the second-worst home record in the majors at 11-20 and trailed 4-3 before scoring three times off the Padres bullpen.
Pinch-hitter Brandon Belt drew a leadoff walk against Trey Wingenter (0-1) and went to third on Joe Panik's single. After Mike Yastrzemski flew out, Longoria lined a 1-1 pitch past left fielder Wil Myers. Belt scored and Panik slid in safely with a headfirst dive to beat the throw home from Tatis.
Wotus made the decision to wave Panik around after being cautious earlier in the game.
"Honestly it was time to take a chance," Wotus said. "If I stopped another one, I think I would have gotten booed out of the place."
Pablo Sandoval followed with a sacrifice fly to score Longoria.
Steven Duggar hit a home run for San Francisco, his first since mid-April.
Fernando Tatis Jr. homered on the first pitch of the game and drove in two for San Diego. Ian Kinsler also went deep but the Padres were done in by their bullpen after a solid start by Chris Paddack.
"You go through these phases in the season where your bullpen's a little snake-bit," San Diego manager Andy Green said. "It happens to most every team at some point in time. We like Trey. He's done a lot of good things for us."
Mark Melancon (3-1) retired three batters to win. Will Smith pitched a 1-2-3 ninth for his 15th save in 15 tries. Longoria backed Smith with a leaping grab on Manuel Margot's hard liner for the second out of the inning.
The Giants needed it all after the strange play in the fifth when the Padres loaded the bases with two outs.
Eric Hosmer hit a sharp comebacker off reliever Trevor Gott that knocked Gott's glove off his hand. The right-hander quickly retrieved the ball, but his throw to first was late and wide and pulled Sandoval off the bag as Chris Paddack scored. Tatis, who drove in the first run of the inning with an infield single, rounded third then made a headfirst slide into home to beat Sandoval's throw. Giants catcher Stephen Vogt threw to third but not in time to get Manny Machado.
"It looked like we were taking infield there for a second," Bochy said.
Gott watched a replay and said shortstop Brandon Crawford likely would have made a play had Gott not intervened.
"A ball coming back at you, it's kind of reflex to try to get a glove on it or knock it down," Gott said. "I tried to throw it. I don't know if I should (have) but I was trying to save an inning. It was an interesting play."
San Francisco's Tyler Beede had a career-high seven strikeouts in 4 2/3 innings but allowed four runs on five hits.
Padres: Austin Hedges started at catcher after sitting out two games with a sprained left ankle. Hedges went 0 for 4 with two strikeouts. ... RHP Dinelson Lamet had five strikeouts in four scoreless innings of a rehab start with Class A Lake Elsinore. Lamet is working his way back after undergoing Tommy John surgery in April 2018.
Giants: C Buster Posey is expected to come off the 10-day injured list Wednesday. The six-time All-Star has been out with a right hamstring strain he suffered in Baltimore on June 1. Posey was placed on the IL four days later, with the move retroactive to June 2. ... Belt was held out of the starting lineup with a sore neck he apparently suffered swinging in the batting cage during Sunday's loss to the Dodgers.
Padres LHP Joey Lucchesi (5-3, 4.21 ERA) takes a two-game winning streak into Wednesday's start. Lucchesi pitched into the sixth inning to beat San Francisco on March 29. RHP Shaun Anderson (1-1, 4.18) pitches for the Giants in his first career start against San Diego.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP—Sports