PHOENIX -- Tuesday night's game had a storybook feel to it for the Arizona Diamondbacks.
At least right up until Pablo Sandoval's two-run homer in the ninth led to a nightmarish ending as the D-backs fell, 2-1, to the Giants at Chase Field.
The D-backs and Giants have faced each other five times this year with all of the games being decided by two runs or less.
"That's what baseball's about, dude," Giants right fielder Hunter Pence said. "These games against Arizona have been unbelievably close, incredible baseball battles. It's like the smallest things go the longest ways."
Right from the start, this one looked to be a nip-and-tuck affair with the two starters -- D-backs right-hander Trevor Cahill and Giants left-hander Madison Bumgarner -- locking horns in a classic pitcher's duel.
Through seven innings, both pitchers were working on three-hit shutouts.
"I felt like everything was down in the zone and I made the pitches when I had to," Cahill said. "I trusted my stuff and let them get themselves out."
Bumgarner would depart first as the Giants pinch-hit for him in the top of the eighth.
San Francisco manager Bruce Bochy then turned to Santiago Casilla, who entered the game not having allowed a home run this season.
That changed when Josh Wilson crushed a 1-2 offering into the bleachers in left for his first home run since June 5, 2011, a span of 95 big league at-bats. That homer, which came when he was with the Brewers, was a game-winning shot.
It seemed like this one would be as well.
The Wilson homer came on the seventh pitch of the at-bat after he fouled off a nasty slider from Casilla.
"He tried to come with a fastball in and I was just thinking to try and put it in play," Wilson said. "Sometimes the barrel meets it just right and I was fortunate to get the homer out of it."
With a lead, D-backs manager Kirk Gibson decided to let Cahill, who had thrown just 82 pitches, hit for himself later in the eighth.
When the ninth started, though, Gibson did not like what he saw. Cahill threw three pitches in the dirt and when leadoff man Angel Pagan lined a single to right, Gibson brought in closer J.J. Putz.
"It's always frustrating," Cahill said of not finishing the game. "I figured he'd leave me in until I got somebody on. I felt like I made a lot of my pitches and kept the ball down all night. I left one up and he got a hit. It's real frustrating when you're so close and you can't finish it out. You're going to kick yourself maybe even more than if I'd only gone three innings and given up 10. It's a bad feeling."
Said Gibson, "He pitched a great game, right on through to the ninth inning. But he threw three to the backstop in the ninth and I didn't want him to get the loss, so I took him out and went to our closer. It's a no-brainer. It's a pretty good lineup you're facing, and it's in the middle of it."
Putz looked sharp in striking out the first batter he faced, Marco Scutaro, and he jumped ahead of Sandoval 0-1 before he hung a split-finger fastball that Sandoval crushed for a two-run homer.
"I made some good pitches on Scutaro, some good pitches on [Buster] Posey," Putz said. "The one to Pablo just didn't come out of my hand. That's pretty much how the split is. If it doesn't come out of your hand right, that's pretty much what's going to happen."
The split has been Putz's out pitch for years, but he has struggled with it in 2013. Hanging splits were hit for game-tying homers earlier this year by Yankees catcher Francisco Cervelli and the Giants' Brandon Belt. So far this year, Putz is 5-for-9 in save opportunities.
"You can't make mistakes to Sandoval like that, he's a really good hitter," Gibson said. "I had confidence in my closer, it didn't work out tonight."
Putz has blown four saves this year, matching his total for all of 2011. Last year he blew five saves. The D-backs have blown nine saves this year, but Gibson said after a tough loss was not the time to say whether he was considering making changes with the bullpen structure.
"Not right now," he said. "We just lost the game, [Putz] feels as bad as anybody. I'm aware of the blown saves. Given that, we've battled back pretty good, actually thought we'd come back and at least tie it up and win the game later."
Steve Gilbert is a reporter for MLB.com. Read his blog, Inside the D-backs, and follow him on Twitter @SteveGilbertMLB. This story was not subject to the approval of Major League Baseball or its clubs.