The Athletics had won six in a row and eight of their last nine.
Oakland owned a 1-0 lead through five innings, but San Francisco came up with five hits against R.J. Griffin (5-4) in the sixth to turn the game around.
Brett Pill opened the inning with a single, moved to third on a double by Brandon Crawford, and both runners scored when Sandoval singled to center.
After Hunter Pence singled, Belt drove in two runs with a double. Griffin had allowed only one hit through the first five innings before the Giants put together their key outburst.
The win went to Barry Zito (4-3), who surrendered a lone run on three hits in seven innings. San Francisco has won each of the last 14 home games in which Zito has started, including the opening contest in last year's World Series.
2014: NFL Cheerleaders [PHOTOS]
Julius Randle breaks leg during NBA debut