SAN FRANCISCO -- San Francisco's Brian Wilson hasn't had many save opportunities the past two weeks. It's been even longer since the Giants' All-Star closer had to pitch more than one inning.
Wilson shrugged off his lack of work and recorded five outs for his 36th save after San Francisco's normally reliable bullpen blew a three-run lead in a 9-7 win over the Arizona Diamondbacks on Sunday.
"I don't like to come into the game unless I'm needed," Wilson said. "I'm not worried if it's 10 days off the mound. It's been a little while since a save opportunity but that's fine. That's not what I'm here for, I'm here to pitch and help us win."
It's only Wilson's third save since Aug. 12 and the first time the right-hander needed five outs for a save since June 16.
More importantly, it helped the Giants avoid being swept by the last-place Diamondbacks and pulled them within five games of San Diego in the NL West. San Francisco remained 1 1/2 games behind Philadelphia for the NL wild card.
"We just don't do anything easy," Giants manager Bruce Bochy said. "We had our hands full in this series. The last thing we wanted to do was get swept."
Jose Guillen hit a go-ahead, two-run single in the seventh inning and San Francisco added an insurance run in the eighth to snap a three-game losing streak.
Jeremy Affeldt (3-3) got two outs for the win while Wilson recorded his 36th save in 38 tries.
The Giants wasted a fine outing by pitcher Matt Cain when three relievers gave up three runs in the seventh. Cain pitched 6 1/3 solid innings, scattering six hits while striking out seven, and left with a 5-2 lead before the bullpen's meltdown.
"Matt deserved the win there [and] I'm mad that I took it from him," said Affeldt, who gave up a two-run double to Adam LaRoche in the seventh and an RBI single to Stephen Drew in the eighth. "They didn't hit us super hard later in the game, they just hit the key hits. I missed my spot in a situation I needed not to miss my spot, and then the next inning I hit my spots and they still got hits."
Drew had four hits for Arizona, including his 12th home run of the season. The Diamondbacks had outscored the Giants 17-3 in the first two games of the series.
"I told these guys they have nothing to hang their heads over," Arizona manager Kirk Gibson said. "They played hard. I'm very happy with the way they played. Some things didn't go our way."
The Giants dropped the first two games of the series after their starting pitchers struggled to get out of the first inning. Tim Lincecum and Barry Zito allowed a combined nine runs in the opening frame and both took the loss.
This time it was San Francisco's bullpen that fell apart and nearly proved costly until Guillen bailed the Giants out.
Guillen, acquired from Kansas City on Aug. 13 after being designated for assignment, couldn't get the ball out of the infield in his first three at-bats before singling off Esmerling Vasquez (1-5) to drive in Sanchez and Aubrey Huff. Guillen later scored on a sacrifice fly by Cody Ross.
"We had the right guy up and he got enough of it," Bochy said. "Guillen, he knows what to do there and he was going to make sure he got a run in and moved a guy over. He was thinking up the middle and got a base hit."
Bochy's bullpen had been solid in August, going 6-1 with a 3.26 ERA in 25 games but stumbled against Arizona. The Diamondbacks scored three runs in the seventh after Cain left, taking a 6-5 lead on Adam LaRoche's two-run double.
The two RBIs give LaRoche 87 for the season, tying Tony Clark's franchise record for first basemen set in 2005.
The Giants answered with three runs in the bottom half and held on for the victory.
Drew homered off Cain leading off the third, then Arizona got some help from the Giants pitcher to score its second run.
Cain struck out pinch-hitter Ryan Church but the ball skipped past catcher Eli Whiteside, allowing Church to reach first on the wild pitch. Church took second and third when Cain uncorked two more wild pitches and scored on Drew's grounder.
San Francisco scored four runs in the third off Arizona starter Rodrigo Lopez.
Drew has a six-game hitting streak and is batting .643 over that stretch. ... LaRoche "tweaked something in his hamstring," according to Gibson and is day to day. ... Bochy said he expects LHP Dan Runzler to be activated from the disabled list Wednesday when rosters are expanded. ... Guillen is batting .372 in 13 games with the Giants. ... Lopez lasted four innings and gave up five runs and eight hits and is winless in his last nine starts. ... The three wild pitches in one inning by Cain were the first by a San Francisco pitcher since Pat Gomez did it on June 23, 1994 at Cincinnati.