SAN FRANCISCO -- His team practically desperate, Madison Bumgarner delivered a boost that could not have come at a better time for the defending World Series champions.
NL West-leading Arizona arrives for a crucial weekend series with the Giants starting Friday.
"We needed to win today in the worst way possible," newly activated outfielder Pat Burrell said.
Bumgarner matched his career high with 11 strikeouts, Jeff Keppinger and Pablo Sandoval hit consecutive home runs in the fourth inning, and San Francisco beat the Chicago Cubs 4-0 on Wednesday to snap a three-game skid and avoid a sweep.
On a day when general manager Brian Sabean began making big changes to his struggling club, Bumgarner (9-12) was brilliant.
"I didn't think about (what was at stake)," Bumgarner said. "But we need to win. And it would be nice to win from here on out."
Keppinger also drove in a run with a bloop single in the fifth off Rodrigo Lopez (4-6), who lost his third straight outing and dropped to 0-5 in eight career starts against San Francisco.
San Francisco began the day a season-high six games behind NL West-leading Arizona, which was hosting Colorado on Wednesday night.
Dazzling while winning his second straight start, Bumgarner allowed a season-low two hits and walked two in eight innings. Manager Bruce Bochy stuck with him after a one-out walk to Geovany Soto in the eighth and Bumgarner got out of it.
"He was tough," said Chicago leadoff man Starlin Castro, who tweaked his troublesome hamstring but didn't consider it serious.
Sergio Romo finished the Giants' 11th shutout with a 1-2-3 ninth that included a strikeout. Music blared through the clubhouse afterward for a group that believes it can rediscover its swagger from last fall's improbable title run.
"I'll say this, it's been a tough go," Bochy said. "To get out of something like we've been going in usually takes a great pitching effort, and we got that from Madison. It puts the team feeling good about themselves. It's a nicer off day after a win. Hopefully it will give us some momentum."
Keppinger drove the first pitch he saw from Lopez into the left-field seats leading off the fourth for his team's first lead in the series. Sandoval then splashed a shot into McCovey Cove beyond the right-field arcade -- right to the eager kayakers who had been waiting to retrieve a rare souvenir in the bay of late.
Sandoval picked up his sixth career splash hit and second this year. It was the third by a Giant in 2011, 58th by San Francisco overall and No. 82 in the history of the 12-year-old ballpark. Barry Bonds, the home run king, has 35 of them.
Lopez has allowed two of Sandoval's splash homers. The first came in 2009 when the right-hander was with Philadelphia.
While this result was encouraging, the Giants realize there will have to be a lot more wins the rest of the way to stay in the playoff hunt.
San Francisco hasn't won a home series in six opportunities since taking two of three from the Brewers from July 22-24, and hasn't won in five straight series overall.
Nobody was too shocked, and some were saddened by the departures of a pair of proven veterans.
"We ran into a road block. We're a good team playing bad baseball for more than a month," Mark DeRosa said. "I don't think they were going to sit still and be idle. ... At some point something had to be done."
Said Burrell: "This isn't a hobby. It's a business. We get paid to win."
The Giants avoided being swept by the Cubs for the first time since May 20-22, 1994, and in San Francisco since Sept. 13-15, 1993, at Candlestick Park.
Cubs slugger Alfonso Soriano, who hit solo home runs in each of the first two games and had homered in four of his previous seven overall, went 0-for-2 with a walk and a strikeout.
Chris Stewart added an RBI double as the Giants' bats produced enough support for Bumgarner after Chicago had outscored San Francisco 12-2 in the first two games. Stewart's fifth-inning single snapped an 0-for-14 funk.
"I hope it gets us going," DeRosa said.
Still, San Francisco finishes up August at 11-18 with 78 runs -- the lowest monthly runs total since the Giants scored 77 in April 2009.
The 11 wins are the fewest in a month since getting 10 victories in April 2009.
Burrell, back from a strained right foot, is set to start Friday. ... Injured Giants LHP Barry Zito, nursing foot and ankle injuries, threw a 50-pitch bullpen session and said it went well. Bochy hopes he can help down the stretch. ... San Francisco is 11-14 at home since the All-Star break. ... Cubs manager Mike Quade is keeping his rotation in order even with Thursday's off day. ... Giants RHP reliever Ramon Ramirez celebrated his 30th birthday. ... San Francisco lined up its rotation to have its three best pitchers going against the Diamondbacks, starting with 10-game winner Matt Cain on Friday night for his fifth 2011 start vs. Arizona. ... The Cubs, who had their first winning month (16-13) since going 19-10 last September/October, return home to host Pittsburgh for a weekend series starting Friday. RHP Ryan Dempster (10-10) takes the mound after losing his last two starts. ... Bumgarner is 6-1 at home.