This was the two teams' second game of the day. The Cubs picked up a 2-1 win when they completed a suspended game from Tuesday.
"I wish we could've finished off the second game," Cubs manager Rick Renteria said. "We're playing against clubs that are competing and our guys are holding their own."
Among Bumgarner's dozen K's were four by Javier Baez. Renteria said pitchers are fooling Baez on pitches out of the zone at this point.
"He's trying to make adjustments," Renteria said. "You see him, he's very conscientious in the at-bat. It's a matter of re-zoning and getting pitches in his hitting area that he can do some damage with. They're little hiccups that will continue to arise that we have to deal with."
Bumgarner screamed and pounded his fist into his glove after getting Baez looking to end the seventh and strand two. It was the lefty's 12th K of the game.
"We have to win all the games we can win right now and that could have been the turning point in the game, depending on what happened there," Bumgarner said. "He was probably my last hitter, so I gave it everything I had to get us back to the dugout."
Bumgarner also hit an RBI single for his 14th win of the season and 10th on the road. Chicago's Travis Wood, on the other hand, is now winless in his last 12 starts, giving up 40 earned runs over 66 innings in that stretch for a 5.73 ERA.
"Every ball they seemed to hit just seemed to go right down the line," Wood said. "They had a lot of doubles, and doubles score runs."
It wasn't that Wood made bad pitches. The Giants' lineup is loaded with good hitters.
"I threw some good pitches that they made contact with and put [the balls] down the line," Wood said. "There was a changeup to [Joaquin] Arias [in the fourth] that he one-handed out. Sandoval hit one at his eyes down the line, good piece of hitting there. He hit a curveball that was going to bounce down the other line. It seemed like everything they made contact with found a soft spot there."
The Giants, who are trying to catch the Dodgers in the National League West, tallied in the first on Sandoval's RBI single.
Chicago had a runner at first and two outs in the first when Ruggiano smacked an opposite-field homer to go ahead, 2-1. One pitch later, Castillo hit his career-high 10th home run, marking the sixth time the Cubs have gone back-to-back this season and third time this month.
"After the initial explosion, [Bumgarner] settled down and started making more pitches," Renteria said.
Posey and Sandoval hit consecutive doubles with one out in the Giants' third to pull within 3-2. In the fourth, Arias doubled with one out and scored on Bumgarner's single despite a strong throw home from left fielder Matt Szczur to tie the game.
Posey, who has been bothered by a sore right hip, launched his 14th homer leading off the fifth to go ahead, 4-3. He began the game with six hits in his last 35 at-bats.
"That's a tough lineup, a lot of good hitters," Castillo said of the Giants. "[Wood] made a lot of good pitches and they hit them. That was bad luck. Posey, Sandoval, [Michael] Morse, that's not an easy lineup. He has to make his pitches to those guys."