PHOENIX (AP) Jake Peavy put an end to San Francisco's slide and gave the Giants more hope of winning the NL West.
Peavy pitched into the eighth inning, Buster Posey homered and San Francisco gained a game in the division race with a 2-1 win over the Arizona Diamondbacks on Tuesday night.
The victory, combined with the Dodgers' 10-4 loss at Colorado, left the Giants three games behind first-place Los Angeles with 11 to play. San Francisco snapped a three-game losing streak and remained 2 1/2 games ahead of Pittsburgh for the NL's top wild-card spot.
''Tonight was a big game,'' Peavy said. ''We had to have it after the way we dropped the last three. I feel very blessed to feel healthy and go out there and be a contributing factor to a team that's fighting for our lives every day.''
Peavy (6-4), acquired from Boston on July 26, allowed a run and five hits in 7 2-3 innings, striking out four and walking one.
''He's been a pleasure to watch,'' Giants manager Bruce Bochy said. ''You just love how he competes out there. He's got so much intensity in every game he throws. His command's been really right on. He's been a real shot in the arm for this club.''
In his last seven starts, Peavy is 6-1 with a 1.13 ERA.
''You've got a good feeling each time he steps on the mound,'' Posey said.
Santiago Casilla pitched a perfect ninth for his 16th save in 20 opportunities.
Josh Collmenter (10-8) gave up two runs and seven hits in eight innings.
The rest of the Giants have trouble with Collmenter's unorthodox overhand delivery. But not Posey. By going 2 for 4, his career average against the Arizona right-hander is .611 (11 for 20) with three home runs.
''Who knows?'' Posey said when asked to explain it. ''Just one of those baseball oddities, I guess.''
Collmenter doesn't understand it, either.
''I don't know, maybe the ball looks like a beach ball to him,'' Collmenter said. ''I am not sure. Up and down, soft and hard, it doesn't matter. He seems to get the bat on it.''
Posey's 21st home run of the season put the Giants up 1-0 in the fourth.
The Diamondbacks tied it in the sixth when Chris Owings tripled to deep center and scored on A.J. Pollock's single.
San Francisco regained the lead for good in the seventh. Hunter Pence and Travis Ishikawa singled, then Brandon Crawford brought Pence home with a sacrifice fly to center.
Crawford had a double and bunt single to go with his sacrifice fly. Pablo Sandoval had two singles for the Giants. Ender Inciarte singled twice for the Diamondbacks.
Crawford didn't just help the Giants at the plate. In the ninth, the shortstop ranged far to his left to field Mark Trumbo's grounder and, falling away as he threw, still got Trumbo out at first on a close play.
''What an athletic play he made there,'' Bochy said. ''It takes a lot of pressure off Casilla, everybody. That was one of the better plays, with what was on the line, that we've had this year.''
If all works out as planned, Peavy's next start will come Monday in the opener of a three-game series at Dodger Stadium. It didn't take him long to start thinking about it.
''I'm not going to lie to you, I was just in the shower and in my mind I was thinking about Dee Gordon, to be honest with you,'' Peavy said. ''Isn't that crazy? Isn't that unbelievable? I was taking a shower thinking, how do we get Dee Gordon out?''
COLLMENTER STRONG AGAIN
Collmenter had another solid outing, although in a losing effort. In his last four starts, he is 2-1 with a 1.02 ERA.
Giants: CF Angel Pagan missed a second straight game with a sore back. Bochy said Pagan has a bulging disk and is day to day, adding that Pagan might require surgery in the offseason. ... 1B Brandon Belt, activated from the disabled list Monday (concussion), was not in the lineup Monday or Tuesday.
Diamondbacks: OF David Peralta remained sidelined with a lower back sprain. He has not played since Sept. 5.
Giants: LHP Madison Bumgarner goes for win No. 19 and the Giants try to win their seventh consecutive series at Chase Field. Bumgarner (18-9, 2.19 ERA) has won five straight, compiling a 1.80 ERA in that span with 41 strikeouts and four walks.
Diamondbacks: Manager Kirk Gibson made a late decision to start LHP Andrew Chafin instead of RHP Randall Delgado in Wednesday's series finale. Chafin will make his second big league start. He pitched five scoreless innings in the second game of a doubleheader in Cleveland on Aug. 13. Delgado was sent back to the bullpen.