SAN FRANCISCO (AP) Matt Cain's first win in more than two months didn't come easily and it certainly wasn't enough to put to rest concerns about the back end of the Giants' rotation.
Hitting a three-run homer, though, had the three-time All-Star and former staff ace feeling a lot better about things.
More importantly, it also helped jumpstart San Francisco's slumping offense.
Cain pitched into the sixth inning after hitting his first home run in four years, and the Giants beat the Cincinnati Reds 9-7 on Tuesday night.
''It's just nice to go out there and be able to contribute,'' Cain said. ''It was a big win for us tonight and something that was definitely needed.''
Brandon Crawford had three hits and two RBIs, and Buster Posey and Denard Span added two hits apiece for the Giants. San Francisco won for only the second time since the All-Star break.
It had been longer than that for Cain.
The right-hander failed to make it past the fourth inning in his three previous starts and wasn't much better against the Reds. He retired nine of his first 10 batters but quickly wore down and left with one out in the sixth after giving up the first of two homers by Adam Duvall.
Cain (2-6) allowed four runs, struck out four and walked one to win for the first time since May 21.
''I had a couple of (pitches) toward the end that kind of ran out over the plate, but for the most part I did a better job of limiting mistakes,'' Cain said.
Duvall added his second home run of the game in the eighth. Joey Votto and Jay Bruce also went deep for Cincinnati.
The Giants broke out of their offensive funk with 13 hits and nine runs, the most by manager Bruce Bochy's club in nearly a month.
San Francisco scored four times in the second capped by Cain's seventh career home run, his first since July 21, 2012.
The Giants made it 5-0 in the third on Grant Green's fielder's choice groundout with runners on the corners. Umpires initially ruled that Green hit into an inning-ending double play, but Bochy challenged second baseman Brandon Phillips' tag of Belt and got the call overturned.
Cincinnati chipped away behind Votto and Duvall before San Francisco pulled away on Crawford's two-run triple in the seventh.
Bruce and Duvall hit back-to-back home runs in the eighth off Sergio Romo. Duvall's homer was his fifth in four games.
Santiago Casilla allowed a run in the ninth but got three outs for his 22nd save. He struck out Bruce with a runner on to end it.
''That's us: We don't do anything easy,'' Bochy said. ''To get a win, it's a good thing right now. We've been in a tough stretch.''
Reds starter Cody Reed (0-5) allowed six runs over five innings in his first career appearance against the Giants.
''We found our way back into the ballgame against their best guys,'' Cincinnati manager Bryan Price said. ''It was a good feeling to be able to come back and rally. It gave the guys a good sign.''
Homer Bailey rejoined the Reds before the game following his latest rehab outing in the minors and is likely to make his first major league start in more than 15 months Sunday when Cincinnati ends its six-game road trip in San Diego. Price said the team is monitoring the right-hander's health after he threw 98 pitches for Triple-A Louisville on Monday. ''I think he's fine, I think he's conditioned, I think he's ready to pitch for us, but we won't announce and make that commitment until he gets through the next 48 hours,'' Price said. ''It could be Saturday, but the probability is it's Sunday.''
Giants: 3B Ramiro Pena left with a bruised groin after taking a bad hop on pinch-hitter Ivan De Jesus' grounder in the seventh. He is day to day. ... 3B Matt Duffy (left Achilles strain) ran the curves around the infield and could begin a rehab assignment this weekend. ... Ehire Adrianza (broken left foot) is getting close to finishing his rehab, but Bochy is unsure what the plans are after that for the infielder.
Reds: RHP Dan Straily (5-6) pitches the series finale Wednesday afternoon. Straily, who began the season in the bullpen, is holding opponents to a .213 batting average.
Giants: LHP Madison Bumgarner (10-5) faces the Reds for the first time this season. The four-time All-Star has won three of his last four matchups against Cincinnati.