Belt, a highly touted prospect who was sent down to Class-AAA Fresno earlier this season, homered in his first at-bat and then drove in two runs with a tie-breaking double in the seventh.
The win was San Francisco's sixth of the season against their longtime rivals and seventh in their last eight games.
Madison Bumgarner (5-9) went eight innings for the win with Brian Wilson notching his 29th save. Bumgarner gave up three runs, all in the third inning, on four hits and struck out seven.
Hong-Chi Kuo took the loss in relief after allowing two runs on two hits and three walked in 2/3 of an inning.
Rafael Furcal drove in two of the three runs in the Los Angeles third, when the Dodgers took a 3-2 lead that held up until the Giants tied it with a run in the fifth.