Floyd led off the inning with a double against Pat Misch (0-3). He was replaced by Felix Pie, who raced to third on a wild pitch. After Mike Fontenot walked, Jason Kendall hit a sharp grounder toward second that kicked off Rich Aurilia's foot and into shallow center, allowing Pie to score.
Pinch hitter Henry Blanco squeezed home Fontenot for another run, as Chicago won its first extra-inning game since May 6 and remained a game ahead of the Milwaukee Brewers in the division. The Cubs had been scoreless in their last 12 extra innings.
Barry Bonds drove in Randy Winn with his 600th career double, and his 1,990th RBI got Bonds within five of tying Lou Gehrig for fourth on the career list.
Bonds finished 1-for-2 and was walked twice to bring his career total to 684.
Carlos Marmol (3-1) pitched two innings for the win. Ryan Dempster got the final three outs for his 20th save in 22 chances.
Floyd had been away from the Cubs for nine days dealing with the death of his father, before returning Tuesday night to hit the go-ahead two-run single in the ninth inning of a 5-1 win over the Giants.
Cubs starter Rich Hill went seven innings, retiring 13 of the final 14 batters he faced. He gave up two runs and six hits, with one walk and 10
Hill, who hasn't won on the road since June 7 at Atlanta, has a 1.96 ERA in his last four starts against the Giants.
Giants starter Barry Zito lasted eight innings, allowing two runs and five hits. He struck out four and did not walk a batter for just the second time this year. Zito is 0-2 in his last six home starts, since beating the Houston Astros on May 23.
The Giants took a 1-0 lead in the first. With two outs, Winn doubled and Bonds was walked intentionally before Bengie Molina hit an RBI single.
Zito retired the first 10 batters he faced, but the Cubs rallied to tie the game in the fourth. Mark DeRosa and Derrek Lee singled ahead of Aramis Ramirez's two-run double.
Ramirez has driven in 35 runs in his last 39 games and leads the Cubs with 76 RBIs.
Notes: The Giants activated C Eliezer Alfonzo from the DL and optioned him to Triple-A Fresno. ... Bonds became the 14th player to reach 600 doubles, three shy of Cal Ripken, Jr. for 13th. ... Giants LHP Steve Kline turned 35 on Wednesday. ... The Cubs have won 14 of the 19 series in which they have scored first. ... Zito improved his average to .104 (5-for-48) with his seventh-inning single. ... Hill recorded at least 10 strikeouts in a game for the fifth time in his career. ... The attendance of 39,548 ended the Giants string of 20 straight sellouts.