SAN FRANCISCO -- Travis Wood did more than just pitch his way out of trouble.
He also hit his way to victory.
"He threw one in there and I was able to put a good swing on it and hit it out of the park," Wood said. "I'm always surprised. I'm not trying to hit home runs."
Welington Castillo also hit a home run for the Cubs, who won their third straight and five of seven despite playing without Alfonso Soriano, who was traded to the New York Yankees on Friday.
"It's tough to lose him," Wood said. "He was the leader of this team, he's been here the longest and he was swinging a hot bat. Guys just have to step up and fill in."
The Cubs' clubhouse broke into spontaneous cheering when Soriano homered for the Yankees and later learned of his game-winning hit.
"He's our boy," Castillo said. "He just needs to keep doing what he's been doing."
For one series, at least, the Cubs found a way to win without their popular ex-teammate.
Pablo Sandoval drove in a run for the Giants, who have lost four straight and seven of eight.
Tim Lincecum (5-11) had two hits in addition to pitching seven innings. He gave up two runs and four hits. He walked two and struck out 10.
"Tim did a great job," Giants manager Bruce Bochy said. "Not only did he pitch well, he got a couple of hits there. It's a shame he couldn't get him the win.
"In all my years I've never seen a team go through such a hard time getting runs in like we're having right now. It's a shame because we're getting such great pitching."
Wood (7-7) allowed an unearned run while walking four and striking out seven. Wood was 1-4 over his previous nine games. He's been involved in 10 one-run decisions.
"Early on it was kind of a grind but it was that way for both of us," Wood said. "I was able to settle down quite nicely."
Pedro Strop threw a scoreless eighth, his 12th consecutive scoreless outing (10 2-3 innings) since joining the Cubs on July 2.
Kevin Gregg recorded the final three outs for his 22nd save in 25 chances, and his third straight of the series.
Wood ended the scoreless tie with his third home run, a solo shot with two outs and on a 2-2 count, in the fifth. It was the first career home run Lincecum has allowed to an opposing pitcher.
Lincecum survived a shaky start to retire 13 of 14 batters until Wood took him deep.
"It was just a couple of location mistakes," Lincecum said. "Except for the two home runs everything seemed to come out of my hand better."
The Giants left the bases loaded in the third and had the bases loaded with no outs in the fifth. Buster Posey's grounder to Luis Valbuena turned into a 5-2 double play before Sandoval doubled to tie the game.
"Thank goodness we got another weird grounder to third we could turn into a double play," Cubs manager Dale Sveum said. "You don't see a force and tag like that too often."
Castillo hit his third home run with two outs in the seventh, giving the Cubs a 2-1 advantage.
"He was behind in the count and I was looking for a fastball," Castillo said. "He gave it to me."
The Giants, who have committed a major league-leading 76 errors, took fielding practice instead of batting practice before the game.
The Giants activated RHP Guillermo Moscosco, whom they acquired in a trade from the Chicago Cubs last week. RHP Yusmeiro Petit was designated for assignment to make room for Moscosco. ... The Giants are scheduled for a White House visit on Monday's day off before starting a series at Philadelphia on Tuesday. Giants Hall of Famer Willie Mays was asked to accompany the team to Washington D.C. and missed the Hall of Fame ceremonies. ... Wood's three HRs and eight RBIs are the most by any pitcher this year. ... The first inning lasted 31 minutes and the pitchers needed a combined 58 pitches to complete it. ... Cubs RHP Scott Baker (Tommy John surgery), who has not appeared in a major league game since Sept. 24, 2011, when he was with the Minnesota Twins, will make his fourth rehab start on Monday. He's 0-2 with a 13.50 ERA in his first three starts. ... RHP Jeff Samardzija (6-9, 3.94) starts for the Cubs when they open a four-game series with the Milwaukee Brewers on Monday night. ... LHP Barry Zito (4-7, 4.92) starts Tuesday night's game at the Philadelphia Phillies. He's 0-6 with a 9.89 ERA on the road.