Updated

Hunter Pence's two-out home run in the ninth inning forced extras and San Francisco scored three runs in the 10th as the Giants took three out of four from the Chicago Cubs with a 10-7 win at Wrigley Field.

"It's a great feeling, but I am just grateful for the team. That's what we're here for. We're out here battling for each other, so it just feels good to help the team out," Pence said.

After allowing the game-tying home run to Pence, Cubs reliever Shawn Camp (0-1) balked in the decisive run with no outs in the 10th. Camp allowed four runs and five hits in 1 2/3 innings.

Pence went 3-for-4 with two runs and a stolen base for the Giants, who remain atop the NL West standings with the win. Gregor Blanco and Nick Noonan each contributed two RBI.

Starlin Castro had three hits to pace Chicago, including his second home run of the season off Giants starter Tim Lincecum, who allowed four runs and struck out four in five innings.

Alberto Gonzalez and former Giant Nate Schierholtz also went deep for the Cubs.

Chicago pitchers combined for five wild pitches in the sixth inning, breaking the MLB regular season record.

Leading 4-1 in the sixth, Cubs starter Edwin Jackson walked Pence and Brandon Belt and allowed an RBI double to Blanco. Jackson then walked Brandon Crawford with the bases loaded and was replaced with Michael Bowden, who gave up the two-run single from Noonan which gave the Giants a 5-4 lead. Jackson was charged with two wild pitches in the frame while Bowden threw three.

San Fran tacked on an insurance run in the seventh on Blanco's second RBI double of the afternoon.

Alberto Gonzalez brought the Cubs deficit to one with his seventh-inning home run, his first since 2011 with the Padres. He added his second RBI on a sacrifice fly, part of a two-run eighth inning for Chicago, to put the Cubs ahead heading into the ninth.

Trailing 1-0 in the bottom of the opening frame, Castro and Schierholtz each cranked two-run home runs to give the Cubs an early advantage, which they were unable to maintain.

"To have the lead like that, and give it up because of walks, then battle back and take the lead and have a chance to put the game away and obviously lose the game was disappointing. It was as tough as any of them so far," Cubs manager Dale Sveum said.

Game Notes

Pablo Sandoval extended his hitting streak to eight games ... Buster Posey, who was given the day off, entered as part of a double switch in the ninth inning and hit an RBI-single in the 10th ... Jackson allowed five earned runs and four walks in 5 1/3 innings ... Chicago hit 0-for-5 with runners in scoring position ... A total of 13 pitchers were used.