David Peralta hit a three-run homer to back 5 1/3 innings from Rubby De La Rosa (1-0), who allowed six runs on eight hits with five strikeouts.
The D-backs gave rookie manager Chip Hale his first MLB win.
Buster Posey went 3-for-3 with a homer and two RBI, and Brandon Crawford homered in the setback.
The defending champs received some troubling news on Tuesday in regards to their pitching staff. Ryan Vogelsong was already making the start in place of Jake Peavy, who was scratched because of back tightness, and the team placed Matt Cain on the disabled list earlier in the day with a strained flexor tendon. The three-time All-Star had been scheduled to start Wednesday's finale of a three-game season-opening series.
Vogelsong (0-1) was tagged for seven runs on six hits and four walks over 4 2/3 frames.
Angel Pagan, who had three hits with two RBI in the season opener, doubled with two outs in the first inning and trotted home on Posey's blast to left center.
The D-backs cut the deficit in half in the home second when Mark Trumbo tripled for the second time in as many days and scored on Lamb's groundout. Peralta then hit a three-run shot in the third to give Arizona a 4-2 lead.
The Giants tied the game with a run in both the fourth and fifth innings. Brandon Belt brought Pagan home with a single in the fourth, and Joe Panik knocked in Vogelsong, who singled to begin the fifth, with a sacrifice fly.
It was not deadlocked for long as Lamb pummeled a 3-2 curveball over the wall in right for three-run homer in the bottom half.
Crawford hit a solo shot with one out in the sixth before Gregor Blanco doubled to end De La Rosa's night. Brad Ziegler entered and served up a run- scoring double to Hector Sanchez that trimmed the deficit to one.
Both offenses stalled from there, and Addison Reed came on in the ninth to nail down his first save of the season.