SAN FRANCISCO -- Nate Schierholtz finished off his first career multihomer game with one memorable drive.
"You never know here," said Schierholtz, who drove a 1-2 pitch from Pat Neshek deep to right. "I was watching (Will) Venable and he was deking me. I didn't know until I heard it come down."
Schierholtz finished with three hits and three RBIs for the Giants, who beat the Padres for just the third time in 12 games at AT&T Park.
"It's hard to have a better game than Nate did," Giants manager Bruce Bochy said.
Javier Lopez (4-1) threw two scoreless innings while Neshek (1-1) picked up his first loss since Sept. 25 with Minnesota at Detroit.
"It was a long night," Schierholtz said. "Pablo tied the game for us and we just tried to scrap out a win."
Sandoval's two-run double came against Mike Adams, who had not allowed a run in 15 of his previous 16 appearances against the Giants.
"He's a great pitcher and I was fortunate enough to get the barrel of the bat on the ball," Sandoval said. "I was 100 percent today. My hand didn't hurt at all."
"That was two good bullpens going at it and it was just the one swing at the end," Padres manager Bud Black said.
The Giants snapped a three-game losing streak.
"Initially I thought it was a home run for sure but then it hung up there," Venable said of Schierholtz's drive. "It was coming down steep. He got just enough of it."
Padres starter Dustin Moseley allowed four runs and five hits over 7 1/3 innings. He struck out a career-high nine and walked one.
"He threw great," Black said. "An outstanding performance. He made the one mistake to Schierholtz."
Moseley was 1/3 over his previous eight games despite allowing no more than three runs in a game over that span. He has the lowest run support of any NL pitcher. Giants starter Madison Bumgarner has the second-lowest.
Bumgarner lasted six innings, allowing five runs and nine hits. He is 1-5 in nine starts at home.
Ludwick had a two-run double in the first, but Torres doubled leading off the bottom half and eventually scored on Sandoval's groundout.
The Padres added a run in the third on Headley's sacrifice fly and in the fourth on Guzman's double.
Schierholtz's fifth home run of the year, a two-run shot that glanced off the right-field foul pole, cut San Diego's lead to 4-3 in the fourth.
Torres sparked the tying rally with a one-out single off Moseley. Adams came in and allowed Brandon Crawford's single ahead of Sandoval's drive into right-center field.
Giants LHP Jonathan Sanchez threw a bullpen session and has another scheduled for Saturday. ... Black is undecided on his Saturday starter, though RHP Aaron Harang (right foot) appears the likely choice. ... Injured Giants C Buster Posey made an appearance in the broadcast booth during the game. ... Giants OF Cody Ross (slight hamstring strain) was out of the starting lineup for the second straight day. ... Padres OF Cameron Maybin hit his sixth triple, the most by a Padre before the All-Star break since Dave Roberts had nine in 2006. ... The Padres stole four bases and improved to 8 of 8 for the series. ... Johnson's RBI was his second since June 4.