SAN FRANCISCO — Buster Posey took off from first on Pablo Sandoval's sixth-inning double with what looked like a good chance of scoring the tying run.
Instead, Arizona shortstop Cliff Pennington made the perfect throw home on a relay, and the first-place Diamondbacks held off a late San Francisco rally to beat All-Star Madison Bumgarner and the Giants 3-1 on Sunday and avoid a three-game sweep.
"It happens. That's the way it goes sometimes," Posey said. "They made a good relay and a good throw to the plate."
Posey got aboard on a leadoff walk in the sixth, and Sandoval followed with a double off the wall. Third-base coach Tim Flannery claimed responsibility for the loss for sending the reigning NL MVP.
"You never want anybody thrown out. I feel terrible," Flannery said. "I feel responsible for not getting Bum the win. It comes with the territory. With nobody out, that can't happen."
Paul Goldschmidt hit a sacrifice fly and a double against Bumgarner, Cody Ross added a late two-run single, and the first-place D-backs bounced back in the series finale.
Randall Delgado (2-3) won in his first career start at AT&T Park, and Goldschmidt's first-inning sac fly got things going against the inconsistent defending World Series champions.
"We couldn't figure him out until later in the game," manager Bruce Bochy said of Delgado.
A day after stranding 13 baserunners and going 2 for 12 with runners in scoring position, the D-backs did just enough against Bumgarner in the 10-game winner's first outing after the All-Star break.
Ross singled in the eighth as Arizona won for just the fourth time in 16 road games.
The Giants were denied their first sweep of Arizona at home since May 10-12, 2011.
"We had a chance to sweep the series but it's big to win the series, so we'll take that," Bumgarner said.
San Francisco won the first two games of the series, but the NL West-leading Diamondbacks (51-17) gained a game back to give themselves a 5 1/2-game cushion over the Giants and remain a half-game ahead of second-place Los Angeles.
Bumgarner, for one, wasn't pointing fingers at the emotional Flannery.
"I don't think anyone is blaming on him except himself," Bumgarner said. "He's a great third base coach and I'm thankful he's part of the team. He takes it personal but you are not going to be right all the time. They had to make two great throws, and they did."
Bochy said Pennington played it well.
"It looked like Buster was going to make it but the shortstop came up throwing," Bochy said. "You hate to see that happen but give them credit for making the relay."
Goldschmidt, 1 for 9 in the first two games of the series, doubled to start the fourth and drew walks in the sixth and eighth innings. Delgado allowed three hits, struck out two and walked four in 5 2-3 innings.
Brad Ziegler finished a crazy ninth that featured two errors for his fourth save in as many tries. The Giants scored on second baseman Aaron Hill's wild throw past first.
"We're in it for the long haul," D-backs manager Kirk Gibson said. "We understand there are going to be a lot of frustrations along the way and we need to play better. We're capable of playing better, cleaner baseball."
Bumgarner (10-6), who didn't pitch for NL All-Star manager Bochy in Tuesday's loss at Citi Field, had his three-start winning streak snapped with just his second defeat in eight starts. He allowed five hits, struck out six and walked three over seven innings in his 20th start of 2013.
"He threw the ball well. He battled through some innings," Posey said. "It's tough when you can't pick up a good outing like that."
The Giants turned a nifty double play to end the fifth. First baseman Brandon Belt caught A.J. Pollock's foul popup and threw to Bumgarner covering first for a double play. A running Pennington, aboard on a leadoff single, was faked out at second when Marco Scutaro threw down his glove as if to tag Pennington – with Pennington realizing too late that the ball wasn't there as he made his slide.
Notes: SS Brandon Crawford returned to the Giants starting lineup after coming off the bench Saturday, a day after he had his left foot spiked by Heath Bell on a play at first base. ... Bumgarner lost for just the third time in 13 starts vs. the NL West. ... On Aug. 16, 2011, against the Giants in his second big league start while with Atlanta, Delgado carried a no-hitter into the seventh inning before now-Arizona teammate Ross' solo home run. ... The Giants placed LHP Jeremy Affeldt on the DL a day after he strained his left groin. He could miss up to six weeks. RHP Jean Machi was recalled from Triple-A Fresno to fill his spot. ... San Francisco RHP Ryan Vogelsong, recovering from two broken bones in his right pinkie, will pitch his first rehab outing in the Arizona Rookie League on Tuesday – likely two innings and about 35 pitches. ... The Giants used 16 relievers in the series.