SAN FRANCISCO -- It's been a long road trip for the D-backs.

And it's not over yet.

The D-backs dropped a 5-4 decision to the Giants on Tuesday night in front of 37,492 at AT&T Park, and the Snakes are now 1-7 on this 10-game road trip that has included previous stops in Atlanta, Philadelphia and Houston.

The D-backs had to like their chances of winning coming into this one. The Giants, after all, were coming off a 14-inning, heartbreaking loss on the road to the Rockies, while the D-backs were well-rested after a day off with ace Dan Haren on the mound.

San Francisco starter Matt Cain, though, was up to the challenge as he held the D-backs to just one hit over the first four innings.

Meanwhile, the Giants were able to get an early lead thanks to a solo home run by Juan Uribe in the second inning.

"Outside of the pitch to Uribe that he jumped all over and hit the home run, he executed the game plan like he wanted to," D-backs manager A.J. Hinch said of Haren.

The D-backs gave Haren the lead in the fifth when they scored a pair of runs off Cain thanks to a catcher's interference call and a two-run double by Stephen Drew.

"I felt pretty good," Haren said. "I kept us in there. Obviously, going against Cain, I know that runs are going to be at a premium, so I was glad I was at least able to keep us there and give us a shot."

The Giants tied the game in the seventh when Travis Ishikawa scored from third on a wild pitch from Haren.

Haren departed after the seventh, and setup man Jon Rauch, who has pitched very well of late, retired the first batter he faced before issuing back-to-back walks.

Ishikawa then followed with a home run into the seats in right to give the Giants a 5-2 lead.

"I didn't get all of it," Ishikawa said. "I knew I hit it well; I was just kind of praying that it would either hit off the wall or get over the head of the outfielder to get the run in."

The homer was obviously the big blow, but it was the back-to-back walks that really stung.

"This one's on me," said Rauch, who was more upset about giving up the two walks than the homer. "You can't give away outs, especially that late in the ballgame, and give them free passes."

"He made a mistake with a cutter that didn't do a ton and that didn't get in like he wanted to, and he made him pay," Hinch said. "He made a good swing at the ball. It's tough to hit the ball out of this ballpark, so you have to tip your hat sometimes to the hitter.

"It's uncharacteristic for him to walk those two guys leading up to it, and that's probably what he'll go home frustrated with are the free passes."

The D-backs made things interesting in the ninth off San Francisco closer Brian Wilson.

With two outs, Augie Ojeda singled, and pinch-hitter Rusty Ryal and Drew each walked to load the bases.

Ryan Roberts then blooped a single to right to score a pair and send Wilson to the showers.

Sergio Romo, though, was able to get Chad Tracy to ground out to end the game.

"We played a complete game," Hinch said. "We didn't quit and we made it interesting off their closer and just couldn't come through at the very end. They delivered a tough blow with the three-run home run, but we responded back. Just another tough loss in a close game that could have gone either way."

And just another tough game on a road trip that already has been far too long.