SAN FRANCISCO -- Within the span of two pitches, Doug Davis went from a job well done to another disheartening setback.

Miguel Montero hit home runs in consecutive at-bats and drove in three but the Arizona Diamondbacks had their modest two-game winning streak stopped in a 8-4 loss to the San Francisco Giants on Tuesday night.

Davis (8-14) lasted four innings, giving up four runs -- all with two outs -- on seven hits. He walked five and struck out three. Davis fell to 1-4 over his last nine starts.

He was in trouble in every inning and gallantly worked himself through a couple of jams and kept the damage to a minimum. That is, until Pablo Sandoval, with two outs, singled on a pitch that was several feet out of the strike zone.

"That guy can hit anything," Davis said. "That was a pitch up at his neck and he still hit it."

That hit would have been meaningless if he had retired Bengie Molina, the Giants' free-swinging catcher. He hit the first pitch halfway up the bleachers in left field.

"Molina was cheating inside and I threw an inside pitch to him," said Davis, who got Sandoval to hit into a double play to escape the second and struck out Molina with two runners on in the first.

The Giants' No. 3 and 4 hitters combined to go 8-for-10 with three home runs, a double and six RBIs.

"They were the difference in the game," D-backs manager A.J. Hinch said. "We always felt like we were one out away from getting out of something, but with two outs they never let up."

The D-backs looked to their No. 3 and 5 hitters for run production. Montero drove in the first three runs on his two-out solo shot in the fourth and his two-out, two-run blast in the sixth.

Justin Upton also got into the act, hitting a solo home run in the eighth.

Davis allowed 13 baserunners overall.

"Walks," he said. "I struggled with them last time and it kind of carried over to this start. Believe it or not, but in the bullpen it was the best stuff I've had all year. I was trying to do a little too much, and when you walk those guys, it's going to hurt."

Davis will need to pitch at least 4 2/3 innings Sunday in Chicago to reach 200 for the year.

"A.J. has given me the opportunity to reach my goal and that's all I can ask for," Davis said. "The rest is up to me. In my last two games I've kept the defense on their heels and kept them out there too long."

Hinch stuck with Davis through 103 pitches.

"We gave them a lot of baserunners and allowed them to create rallies," Hinch said. "We couldn't get out of anything. We didn't swing the bats very well either."

Montero recorded his first multi-homer game of the season and the third of his career.

"It was the long ball tonight," Montero said. "I mean, it was like a home run derby, and it was a long game. It was miserable because it was too long and it looked like the ball was flying."

His two-run shot in the sixth landed in McCovey Cove, the body of water just beyond the right-field bleachers, for a 'splash hit.'

Montero became the third D-back to record a splash hit, joining Luis Gonzalez, who hit two, and Mark Grace. He's the seventh-youngest player to record a splash hit.

"We have to keep grinding until the end," he said. "I know we're out of it, but you try to finish strong so that it carries over for next year."

Hinch also indicated that nothing has changed for this weekend as far as the starting rotation, even though both candidates for Saturday's start, Daniel Cabrera and Yusmeiro Petit, each pitched an inning against the Giants.

"One will pitch and one won't. We'll talk about it tomorrow," he said.