Brandon Belt went 3-for-5 with a solo homer and three runs scored and Angel Pagan finished with two hits and two RBI for the Giants, who saw starter Madison Bumgarner surrender four unearned runs on six hits over four innings.
Jean Machi (1-0) picked up the win after working 1 2/3 scoreless innings.
Gerardo Parra drove in three runs, while Mark Trumbo and Aaron Hill finished with two RBI apiece for the Diamondbacks, who fell to 0-3 on the season. Arizona had opened its regular season on March 22 in Australia against the Dodgers. They were swept in the brief two-game set.
Brandon McCarthy started for the D-backs and surrendered five runs on six hits over 6 2/3 innings. Addison Reed (0-1) was pegged with the loss after surrendering Posey's go-ahead blast in the ninth.
Notable deaths of 2014 [PHOTOS]