San Francisco, CA (Sports Network) - Cody Ross provided a two-run single and Brad Ziegler benefited from an unconventional double play in the ninth to secure an Arizona Diamondbacks' 3-1 victory over the San Francisco Giants.

The D'backs held the Giants scoreless for the first eight frames, but Ziegler was in a jam after the first two batters for the Giants reached in the ninth.

He got Kensuke Tanaka to ground to short where Cliff Pennington fielded the ball and flipped to second to get the force out, but second baseman Aaron Hill's throw sailed wide of first base and Hunter Pence came in to score.

Tanaka tried to advance on the error, but was erased when first baseman Paul Goldschmidt fired a strike to second from foul territory. That left the bases empty and the Giants could not produce another threat.

Goldschmidt lifted a sacrifice fly in the first inning and Randall Delgado (2-3) made the advantage stand, working 5 2/3 scoreless innings while holding the Giants to just three hits and four walks.

Ross went 2-for-3 and provided some insurance by scoring a pair on his single in the eighth with the bases loaded. Martin Prado ended 3-for-4 with two runs scored.

With the victory, Arizona was able to avoid a three-game sweep and cling to its half-game lead over the surging Los Angeles Dodgers for the top spot in the NL West.

"We're ready for the long haul and we understand there's going to be a lot of frustrations along the way," said D'backs manager Kirk Gibson. "We know we need to play better."

Giants All-Star Madison Bumgarner (10-6) was a hard luck loser, yielding just one run on five hits over seven innings. He struck out six and walked three while his club went 0-for-6 with runners in scoring position.

"He's been throwing great all year, that's why he made the All-Star team," said Giants manager Bruce Bochy. "He gave us a chance to get the sweep."

Goldschmidt's sac fly in the first followed a one-out triple from Prado to open up the scoring.

The Giants had a runner on base in five of the first six innings, but failed to push a run across in any of the frames.

Buster Posey led off the sixth with a walk, but was erased at home plate when he tried to score on Pablo Sandoval's double into the left-center gap. He arrived at the plate just behind Pennington's perfect relay throw.

Arizona had little success against Bumgarner, and capitalized upon his exit to start the eighth, with Prado, Goldschmidt and Hill each reaching in succession with one out against reliever Sandy Rosario.

Javier Lopez came in to retire Miguel Montero, but Jean Machi was called upon to face the righty Ross, who was able to slap a base hit over second base to plate two runs and open a 3-0 lead for the D'backs.

Game Notes

Bumgarner had won six of his past seven starts coming into Sunday ... Machi was recalled on Sunday after the Giants placed pitcher Jeremy Affeldt on the 15-day disabled list ... Delgado has not allowed more than three earned runs in any of his eight appearances this season.