Will Venable homered and threw out the 1, to salvage a three-game series.
Aaron Harang (13-5) outdueled Matt Cain, allowing just one run on four hits and three walks in seven innings for San Diego, which was mired in a 1-11 funk before hurting its division rival's playoff chances.
Cain (11-10), making his 200th career start, wound up on the losing end after surrendering two runs on four hits over seven frames.
"[Cain] did a great job. ... We just couldn't get any runs for him," Giants manager Bruce Bochy said.
The setback dropped the reigning World Series champions seven games behind NL West-leading Arizona with 19 left to play.
San Diego broke a 1-1 tie in the sixth when Cameron Maybin doubled with two outs and scored on Jesus Guzman's dribbler through the left side. Guzman's single came on a 3-0 count, and Venable made sure the precarious lead stood in the next half-inning.
A single and an error with one out left runners on the corners for Pat Burrell, and the pinch-hitter lofted a short fly ball to right that Venable caught on the run. With his momentum carrying him forward, Venable threw a strike to the plate, nailing Brett Pill in a bang-bang play to end the frame.
"[Venable] got the good exchange out of the glove to the hand. He made an accurate throw on line," Padres manager Bud Black said. "It was a critical junction double play."
Hundley gunned down pinch-runner Darren Ford trying to steal second in the eighth, quelling a Giants rally before it started, and Maybin added an insurance run in the bottom half with an RBI triple off Jeremy Affeldt.
Heath Bell, who recorded the final out in the eighth, closed it out in the ninth for his 36th save and first since August 23.
Venable sent Cain's second offering into the seats down the right-field line, extending a Padres record with his fifth leadoff homer of the season.
Pill, who went deep in his first career at-bat on Tuesday, added another blast in the fifth to tie things.
Cain became the fifth Giants pitcher to reach 200 innings in five straight seasons...The last time the Giants swept the Padres in San Diego was August 14-17, 2006...San Fran has Thursday off before taking on the Dodgers for three games at AT&T Park...The Giants had seven hits to San Diego's five, falling to 60-9 when out-hitting the opposition.