Paul Goldschmidt homered and drove in three 1, in the finale of a three-game set.
Miguel Montero added a solo homer for the D-Backs, who avoided a sweep and remained five games up in the NL West after the Giants won in Denver earlier Sunday.
Arizona, whose magic number is five, opens up a nine-game homestand on Monday against lowly Pittsburgh.
Joe Saunders (12-12) worked 8 2/3 innings, scattering seven hits and one unearned run. J.J. Putz recorded the final out with two runners in scoring position to earn his career-best 41st save.
"The Giants have been playing great, they're on a big winning streak, so we needed to match it. We did today," Diamondbacks manager Kirk Gibson said. "Saunders was outstanding. He was in control the whole game."
Jason Bartlett's third-inning RBI groundout was the lone offense for the Padres, who have dropped four of six.
Aaron Harang (13-7) pitched well in defeat, allowing eight hits and two runs in six full frames.
"Our starting pitching did a good job," Padres manager Bud Black said. "With the exception of today, our bullpen did a nice job as well. We just couldn't string together enough outs late in the game."
Trailing 2-1, Harang exited for Josh Spence, who walked Gerardo Parra before giving way to Brad Brach. He uncorked a wild pitch that moved Parra to second, then Aaron Hill's base hit brought in a run. An error on San Diego left fielder Kyle Blanks moved Hill all the way to third, and three batters later he scored on a Goldschmidt base hit.
In the ninth, Justin Upton was hit by an Erik Hamren pitch, moved to third on Hamren's errant pickoff, then scored on a Goldschmidt sacrifice fly.
Saunders looked like he was going the distance for the second time this season after retiring the first two Padres in the bottom of the ninth, but left after singles from Blanks and Alberto Gonzalez.
Putz came on and fanned pinch-hitter Nick Hundley to end the game.
San Diego got on the board in the third, as Cameron Maybin singled, stole second and took third on Montero's wild throw, then scored on Bartlett's grounder.
Montero atoned by hitting a leadoff homer in the fourth, and Goldschmidt put Arizona ahead with his own leadoff blast in the sixth.
Arizona won 11 of 18 meetings against San Diego this year, but just four of nine on the road...Hill, Upton, Goldschmidt, Chris Young and John McDonald all posted two hits for the D-Backs...San Diego fell to 23-43 against NL West clubs...Putz has over 40 saves for the first time in his career. He had 40 with Seattle in 2007.