Cliff Pennington had two RBIs and scored the winning run for the Diamondbacks, who won the final two games of the series. Miguel Montero also drove in two runs for Arizona.
Michael Morse hit a two-run double that gave the Giants the lead, but an error by third baseman Pablo Sandoval allowed the tying run to score in the eighth and San Francisco fell in extra innings to lose their first home series since last August against Boston.
Pennington hit a one-out single off Yusmeiro Petit (0-1) in the 10th and then stole second base on a 2-2 pitch to Campana with two outs. Campana then blooped a single just over the outstretched glove of second baseman Brandon Hicks to score the go-ahead run.
J.J. Putz (1-0) pitched a scoreless ninth for the win and Addison Reed got three outs for his third save in as many chances.
The Diamondbacks failed to score in the seventh after loading the bases with no outs, but got the tying run an inning later on Sandoval's bad throw.
With runners on first and second and two outs in the eighth, Campana hit a slow grounder to Sandoval, who rushed his throw to first. The ball sailed over Brandon Belt's head allowing Gerardo Parra to score the tying run from second.
Sandoval had a chance to make up for that mistake in the bottom half but couldn't deliver. The Giants loaded the bases with one out with help from a fly to center that Campana appeared to lose in a flock of seagulls to give Brandon Crawford a leadoff double.
Belt hit a fly ball to left field that was not deep enough to let Crawford tag from third. Sandoval then flied out to deep right to end the inning.
The Diamondbacks jumped on top early against Ryan Vogelsong with a two-run single by Pennington in the second inning and a two-run double by Montero in the third to take a 4-1 lead.
The Giants' hitters chipped away after the early deficit, getting a run in the third on the first bunt single of Buster Posey's career when he surprised Arizona with a two-out bunt with Angel Pagan on third.
Back-to-back doubles by Morse and Crawford to open the fourth to make it 4-3 and Morse's double off Will Harris in the fifth gave the Giants the lead.
NOTES: Arizona manager Kirk Gibson unsuccessfully challenged a play at second base in the first inning when Tony Campana was caught stealing to end the inning after a strikeout to Paul Goldschmidt. ... The Giants held a pregame ceremony honoring their former home, Candlestick Park, which is set to be torn down later this year. ... Madison Bumgarner (1-0) takes the mound for the Giants on Friday when they open a series Jorge De La Rosa (0-1) and the Colorado Rockies. ... Brandon McCarthy (0-1) is set to take the mound for Arizona on Friday in the opener of a three-game series against the Los Angeles Dodgers.