Didi Gregorius scored the go-ahead run on a wild pitch in the 11th inning and the Arizona Diamondbacks escaped AT&T Park with a 6-4 win over the San Francisco Giants.
The Giants fought back from a four-run deficit and sent the game to extra innings on Brandon Belt's pinch-hit two-run homer in the ninth. The hosts ran themselves out of the game-winning run in the 10th when Cody Ross easily threw out Pablo Sandoval trying to score from second base, and a sloppy 11th decided the outcome.
The Diamondbacks scored a pair off Santiago Casilla (2-2), and Matt Reynolds closed out the win in the bottom half after closer J.J. Putz failed to do so in the ninth.
"Going through a rough patch," said Putz. "I've been there before, I'll get over it. That's pretty much it."
Arizona improved to 3-5 on a road trip that ends Wednesday afternoon in the rubber match of this three-game series.
The Giants had won seven in a row at home and four straight overall.
Arizona staked Patrick Corbin to an early 4-0 lead, and the 23-year-old lefty cruised through the first seven innings before finding trouble in the eighth.
Andres Torres led off with an infield single and raced around to score on Brandon Crawford's triple to center field. The Diamondbacks conceded a run on pinch-hitter Hector Sanchez's groundout to third.
The Giants pulled even in the ninth, as Hunter Pence greeted Putz with a double to the left-field gap prior to Belt crushing a 2-2 pitch into the right-field seats. Belt also had the game-winning hit as a pinch-hitter in the series opener.
"I feel like I've seen the ball well in the past couple of days. That's helped me stay calm in those situations," said Belt.
Ross sent the game to the 11th when he threw out Sandoval at home by half the baseline. Sandoval had hit a two-out double and was trying to score on Pence's base hit to right.
Gregorius hit a one-out double in the 11th and moved to third when Belt couldn't handle Sandoval's throw from third on a ground ball hit by pinch- hitter Alfredo Marte. Gregorius slid in with the go-ahead run on a wild pitch, and Gerardo Parra added an insurance run with an RBI double.
After Brad Ziegler (1-0) survived the 10th, Reynolds secured the win with his first career save.
Arizona put two on the board in the first inning. With runners on first and second, Paul Goldschmidt sent a double down the right-field line that fell in front of a diving Pence and plated Parra, who reached on Crawford's error.
Martin Prado crossed the plate on Miguel Montero's groundout, then worked a walk in front of Goldschmidt's tape-measure home run in the third.
Matt Cain gave up four runs and remained winless on the year. His ERA actually fell to an unsightly 6.59 after giving up four runs -- three earned -- on five hits over six innings of work.
Corbin allowed just two runs on six hits while striking out seven with no walks in 7 1/3 innings ... The Giants have not won in Cain's last six starts dating back to last season ... The Giants came in 9-1 against the rest of the NL West ... Giants reliever Sergio Romo issued a walk in the 10th, ending a streak of 38 straight games without allowing a free pass.