PHOENIX -- The Arizona Diamondbacks have made a habit of winning late. While the result is rewarding, the process is not.
"It's just a not fun way to play baseball," Eric Chavez said after his one-out, opposite-field single in the ninth inning gave Arizona a 4-3 victory over San Francisco for the Diamondbacks' 12th walk-off victory this season.
The Diamondbacks (69-65) lead the majors with 29 one-run victories and 15 extra-inning victories as they try to get closer in the National League wild card race.
"You just don't want to play like that," Chavez said. "You want to be able to tack on runs and get shut-down innings and win the ballgames you are supposed to and not go into extra-innings. We are good late. I don't know what that means, but that was a good win."
Willie Bloomquist singled to open the ninth inning against Sandy Rosario (3-2) and went to second on Adam Eaton's sacrifice bunt. Paul Goldschmidt was intentionally walked to bring up Chavez, whose walk-off hit was his first since an 11th-inning home run against Boston on June 4, 2007.
"You have to walk him there. He's got some big hits in late innings against them," Chavez said of Goldschmidt, who leads the NL with 104 RBIs.
Martin Prado had three hits and scored a run for the Diamondbacks and Miguel Montero had two hits, an RBI and a run. Bloomquist added three singles.
Prado had 43 hits in August, the most in the National League and one behind Detroit Tigers designated hitter Victor Martinez for the major league lead. Prado led the NL with 30 RBIs in August.
Brad Ziegler (8-1) pitched a 1-2-3 ninth inning for Arizona.
"We get the feeling that if we keep it close, we are going to find a way to win. It's been pretty crazy," Ziegler said.
Hunter Pence had three hits for the Giants (60-75) and Gregor Blanco hit his second homer of the season and his first since June 14.
"They executed and we were in a tough spot," San Francisco manager Bruce Bochy said of the Diamondbacks' ninth-inning rally.
"You walk one guy to see if you can a double play ball, but that ball got too much of the plate there. They got the leadoff hitter and that puts pressure on you."
Blanco homered with one out in the seventh inning to end Trevor Cahill's shutout bid when the Giants recovered from a 3-0 deficit to tie the score.
Angel Pagan singled off Cahill's glove hand, stole second, took third on a wild pitch and scored on a triple by Marco Scutaro to knock Cahill out of the game.
Buster Posey's two-out single to right field tied it at 3 against reliever Josh Collmenter. Posey is 6-for-8 with two homers and seven RBIs against Collmenter in his career.
Prado doubled to right-center field to open Arizona's' three-run fourth against Ryan Vogelsong and went to third on Aaron Hill's single to left. Montero singled to right and Gerardo Parra followed with a sacrifice fly. After Cahill bunted Montero to second base, Bloomquist singled to center to make it 3-0.
"That one inning they got super-aggressive on me and some of the pitches weren't that bad," Vogelsong said. "They just came out swinging. I was trying to throw balls off the plate and they were still getting hits. Just a tough inning there."
Cahill gave up nine hits in 6 1/3 innings in his first start since Aug. 22. He pitched four scoreless innings in a 12-7, 18-inning victory over Philadelphia last Sunday and was pushed back.
NOTES: Arizona OF Cody Ross spoke to the media for the first time since the Aug. 13 surgery to repair a broken bone in his hip suffered Aug. 11. Ross said doctors assured him the injury was not career-threatening and that he could expect to resume full baseball activities "by the middle part of spring training-ish, somewhere in there," Ross said. "That's the goal." ... RHP Yusmeiro Petit, who will start for the Giants on Sunday, won nine games in 56 appearances (35 starts) with the Diamondbacks from 2007 to 2009. He won his only start for San Francisco this season, beating Colorado on two runs in six innings last Tuesday. ... Giants RHP Matt Cain (right forearm contusion) threw a bullpen session Saturday and remains on track for a start against Arizona on Sept. 7, the first day he is eligible to come off the disabled list.