Posey's drive to straightaway center was his second homer of the year and in two days.
Belt's first career walkoff hit came against Tony Sipp (1-1), who allowed a leadoff single to Andres Torres. Brandon Crawford sacrificed him to second.
Jose Mijares struck out two in the ninth before yielding Cliff Pennington's double. Closer Sergio Romo (1-1) relieved in a double switch as Belt entered at first base. Romo retired pinch-hitter Eric Hinske on a first-pitch grounder.
Belt delivered hours after manager Bruce Bochy and hitting coaches Hensley Meulens and Joe Lefebvre met with him during batting practice and urged the struggling first baseman to slow his body movements down. Joaquin Arias started in his place.
Arizona played its third straight one-run game.
Cody Ross hit a two-run single against the team he helped win the 2010 World Series and pitcher Wade Miley hit a towering, tiebreaking drive for his first career home run. But the Diamondbacks couldn't hold a 4-2 lead.
Eric Chavez also hit a solo homer for the D-backs.
Miley crushed a 2-0 pitch deep into the right field arcade in the fifth off Ryan Vogelsgong—and the ball was thrown back onto the field, so the pitcher might have a souvenir to take home.
In the sixth, Ross drew cheers with a sensational diving catch near the foul line in right field to rob Posey of a likely extra-base hit. Ross then got to his knees and quickly threw to the infield as shortstop Didi Gregorius clapped.
The Giants gave up home runs to a third different opposing pitcher this month, the first time they had done so in the same calendar month since June 1953.
Vogelsong has allowed one homer in three of his four starts and each of his last three. The right-hander was tagged for two homers in a game for the first time since allowing three to Atlanta on Aug. 24 last year, the only time he did so in 2012.
He loaded the bases on just 12 pitches to start the game—back-to-back singles by Gerardo Parra and Martin Prado followed by a seven-pitch walk to Paul Goldschmidt before Ross' bloop single that went past leaping second baseman Marco Scutaro.
That hit by Ross, the 2010 NL championship series MVP for the Giants, ended a stretch of 21 shutout innings by San Francisco's pitchers after consecutive shutouts in a weekend sweep of the Padres.
The Giants added those two runs right back in the bottom half with three straight one-out doubles, including those by Pablo Sandoval and Posey to drive in runs after Scutaro got things started.
Goldschmidt walked in his first two plate appearances then was hit by a pitch in the fifth.
Miley remains winless in three career starts and four total outings against the Giants.
At the plate, Miley was 0 for 5 this season and 12 for 83 lifetime (.145) with a pair of doubles before the homer.
San Francisco athletic trainer Dave Groeschner and Bochy checked on Posey in the top of the second after a bouncing pitch hit him in the chin area of his mask. The reigning NL MVP and batting champion stayed in the game.
The Giants are in a 15-game stretch against the division, going 9-1 so far versus the West. Monday's game kicked off the first of 19 between the rivals who were an even 18-18 in their matchups the past two years.
NOTES: Giants 1B coach Roberto Kelly will miss the series to attend a family graduation in Panama. Shawon Dunston worked in his spot for Monday, and Bochy might change that Tuesday. Kelly is expected back with the team Friday at San Diego. ... Ross hadn't been back to AT&T Park since signing with Boston before the 2012 season. Even while playing for division rival Arizona, the bearded, smiling Ross is still a beloved figure in San Francisco. "This place will always have a special place in my heart," Ross said. "I've already gotten a lot of people, just out on the street, saying 'Welcome back' and 'Good to see you' and stuff like that. It's been great so far."