PHOENIX -- Sure the D-backs' bullpen gave up the go-ahead run in the sixth inning, but the relievers recovered after that and retired 20 of the next 21 Giants who came to the plate.
In the meantime, the Arizona offense was able to tie the game before finally winning it, 6-5, thanks to Stephen Drew's single to right in the 12th inning.
The win snapped a three-game losing streak for the D-backs, who finished the homestand with a 4-5 mark and now take to the road for a six-game trip to Cincinnati and New York.
The D-backs had allowed seven first-inning runs in their previous three games, digging themselves into early holes. On Sunday, though, they jumped out to a 3-0 lead in the third against Madison Bumgarner.
Arizona led, 4-1, heading into the sixth, and starter Barry Enright seemed to be in control. The right-hander did not allow a hit until there were two outs in the fourth -- a homer by Aubrey Huff -- and that was his only blemish through five.
Things fell apart for him in the sixth, as the Giants scored four runs to grab a 5-4 advantage. You could forgive the D-backs if they started thinking, "Here we go again," given that the Giants had won 15 of the previous 18 meetings between the two teams.
The D-backs, though, rallied to tie things in the eighth, when Ryan Roberts' two-out single to left scored Xavier Nady.
Meanwhile, the D-backs' bullpen was mowing down the San Francisco hitters.
After Esmerling Vasquez allowed the go-ahead homer to Pablo Sandoval, the only other hit the relievers allowed was when Juan Gutierrez gave up a single in the seventh.
David Hernandez tossed a perfect eighth, J.J. Putz did likewise in the ninth and 10th and then Josh Collmenter, who was making his Major League debut, shut the Giants down in the 11th and 12th.
With one out in the bottom of the 12th, Giants reliever Dan Runzler, who was in his third inning of work, walked Justin Upton and Chris Young.
San Francisco manager Bruce Bochy then brought in side-arming lefty Javier Lopez to face the left-handed-hitting Drew.
Lopez is notoriously tough on lefties -- holding them to a .111 mark since joining the Giants last year -- and he had yet to allow a hit this year with runners in scoring position.
"When you see him one time, it's really tough," Drew said. "It's not easier when you get three or four at-bats against him, because he's still a tough guy to try and see the ball off of. But I knew what he had, and was just trying to get a ball up that I could handle and tried to put a good swing on it."
After taking a slider for a ball, Drew grounded a fastball through the hole at second and Upton raced home safely just ahead of the throw.
"You guys know how I feel about Stephen. That's why I bat him where I bat him," Gibson said referring to the fact that he hits Drew fifth, even though a left-hander was starting on Sunday. "Lopez dominates lefties, so that was a great hit right there."
It was the third RBI of the game for Drew, who drove in a pair with a triple in the third.
The win went to Collmenter, who was recalled from Triple-A Reno on Friday. It was a pressure-packed situation in which to debut, but Collmenter was helped by the fact that he had faced San Francisco hitters like Buster Posey before in the Minors.
"The first warmup pitches in the bullpen, it kind of hit me that this was happening," Collmenter said. "But after that I told myself just to calm down, it was just another game. I've faced Posey and [Brandon] Belt before, so it was kind of a couple of familiar faces there -- so I kind of knew how to get those guys out. Just paid attention to the game, what other pitchers were doing, and tried to stay within myself and execute the pitches that I could."
The last time Collmenter pitched in relief was his first-ever professional game back in 2007.
"It was different warming up and learning how long it actually takes me to get loose, because I'm used to having a half an hour before a game to get ready. So that was something new, as well," Collmenter said. "I just wanted to make sure I threw strikes, worked the corners and executed the pitches that I knew how -- and tried to leave as little of the plate as possible with each pitch, and hopefully they'd get themselves out."