PHOENIX - San Francisco Giants manager Bruce Bochy knew his team's struggles with runners in scoring position would balance out. There are just too many good hitters for it to continue.

Buster Posey, who's had his share of troubles with men on, proved him right.

Posey hit a two-run double in the ninth inning and Hunter Pence had his 200th career home run to lead the Giants to a 5-3 win over Arizona Diamondbacks on Saturday night.

"The silver lining with some of our struggles with runners in scoring position is they usually get back to who they are, it balances out," Bochy said. "That's a huge hit against a tough pitcher."

San Francisco led 3-1 after Jake Peavy's six strong innings, but the bullpen couldn't hold the lead.

Jean Segura pulled the Diamondbacks within one on an RBI groundout in the seventh inning and pinch-hitter Phil Gosselin tied it with a sacrifice fly in the eighth off Hunter Strickland (1-0).

The Giants loaded the bases against Daniel Hudson (1-1) in the ninth and Posey bounced a ground-rule double into the pool deck in right centre. Posey entered the game hitting .143 with two outs and runners in scoring position and had the first hit in 29 at-bats by right-handers against Hudson this season.

"The ninth inning was a tough one," Diamondbacks manager Chip Hale said.

The Giants had 12 hits, four by Denard Span, who is 8 for 17 on the road trip so far. Cory Gearrin pitched the ninth with Santiago Casilla needing a rest day, working around a single in the ninth for his first save.

"Really happy with the way we all played," Peavy said. "A huge knock there by Buster to keep the momentum on our side."

Peavy, the 2007 NL Cy Young Award winner, got off to a slow start this season, allowing at least four runs in five of his seven starts for an 8.47 ERA.

He had a decent outing his previous start and overcame a bout with a stomach bug the night before to pitch well against the Diamondbacks.

Peavy gave up a run-scoring to double to Owings in the second inning, but limited the damage by stranding runners at second and third. He struck out five and walked two.

"Really, he backed off a little, didn't put as much effort into it, really had a smooth delivery going," Bochy said. "The ol' less is more and it worked for him."

Patrick Corbin carried a 15-inning scoreless streak against the Giants into Saturday's game — dating to July 19 — but that ended quickly with Joe Panik's run-scoring single in the first.

Pence has enjoyed hitting against the Arizona left-hander, entering Saturday's game batting .476 with three homers and seven RBIs lifetime against him.

Pence got to Corbin again in the fourth inning, digging out a low pitch and hitting it off the top of the left field wall for a two-run homer to put the Giants up 3-1.

"I thought it was a good pitch," said Corbin, who allowed three runs on nine hits and struck out four in 6 1/3 innings. "He seems to do that off me."

NUMBERS

The Diamondbacks have ground into eight double plays this series, one short of the team record set twice. ... Gearrin's save was his second career, with May 20, 2013 against Minnesota. ... Arizona's Paul Goldschmidt ended an 0-for-11 streak with a single in the eighth inning and scored on Gosselin's sacrifice fly.

TRAINER'S ROOM

Giants: RHP George Kontos (right flexor strain) joined the team after pitching consecutive games with Triple-A Sacramento and is expected to be activated in San Diego next week.

Diamondbacks: OF David Peralta was expected to start hitting off a tee to test out a sore right wrist has kept him out of the past six games.

UP NEXT

Giants: RHP Matt Cain is 0-5 with a 6.69 ERA heading into Sunday's series finale against Arizona.

Diamondbacks: RHP Rubby De La Rosa, Sunday's starter, is 4-1 with a 3.62 ERA in seven career games against the Giants.