SAN FRANCISCO -- Kyle Schwarber has just four hits in his last 29 at bats, though all have been for home runs. He set a club record along the way.
Schwarber, Miguel Montero and Starlin Castro all hit home runs in support of another solid outing from Jake Arrieta, and the Chicago Cubs beat the San Francisco Giants 8-5 Tuesday night for their sixth straight win.
Schwarber's towering, three-run homer in the third set the tone for the Cubs, who have won 21 of 25 games to pull 7½ games ahead of the Giants for the second wild-card spot.
More from FoxSports
He hit his 12th home run within his 42nd game, the fastest Cubs player to do so since 1900.
''I've been struggling lately but I felt good in the box today,'' Schwarber said. ''I still have to learn to put yesterday behind and move on. We're just trying to maintain our focus throughout the game.''
Arrieta (16-6) had his 13th consecutive quality start, the longest streak by a Cubs pitcher in 23 years. He allowed an unearned run on four hits in six-plus innings.
''Once we got the three runs, I'm feeling pretty good about my chances to win,'' Arrieta said.
Arrieta, who took over the major-league lead for wins, walked one and struck out eight, lowering his ERA to 2.22, second in the NL behind Los Angeles Dodgers' Zack Greinke's 1.67.
Hector Rondon pitched the ninth for his 24th save in 28 chances. He's given up two runs over his last 39 innings (0.46 ERA).
Montero added a two-run homer in the fourth and Castro, who was a triple shy of the cycle, hit a solo shot in the sixth.
''That might have been Starlin's best day of the year,'' Cubs manager Joe Maddon said. ''Not just his offense. He made some nice plays on defense too.''
Matt Cain (2-4) lasted five innings, giving up six runs and eight hits. He walked two and struck out three. Cain lost his third straight decision and fell to 0-3 over six starts since his last win on July 22.
In nine innings against the Cubs this season, Cain has allowed 11 earned runs and 14 hits.
''He was locked in the first two innings and just lost it there,'' Giants' manager Bruce Bochy said. ''It just looked like his slot changed a little bit and the ball started flattening out.''
Arrieta retired the first 10 batters he faced before allowing a single to Matt Duffy, who had two hits. The lone run scored as a result of his throwing error in the sixth. Brandon Belt drove in the run on a groundout.
Andrew Susac drove in three with a double and Gregor Blanco drove in a run in the eighth that pulled the Giants to 8-5.
Arrieta also doubled and scored a run on Brandon Crawford's fielding error, ending a season-best eight-game errorless streak for the Giants.
The Cubs moved into a third-place tie in the NL with the Cincinnati Reds, each with 132 home runs. Only the Dodgers (150) and Colorado Rockies (143) have more.
The Cubs improved to 5-0 against the Giants this year.
Giants: LHP Jeremy Affeldt was placed on the 15-day disabled list with a left knee subluxation he sustained while playing with his children on Monday. ... RHP Mike Broadway was recalled from Triple-A Sacramento to take Affeldt's place. Broadway appeared in six games with the team earlier in the year, recording a 3.68 ERA.
Cubs: RHP Kyle Hendricks (6-5, 4.03) is 4-1 with a 3.43 ERA over his last 10 starts.
Giants: Jake Peavy (3-6, 4.35), a three-time all-star and former Cy Young Award winner, is 8-6 with a 2.81 ERA in 17 starts against the Cubs.