St. Louis committed three errors leading to three unearned runs while suffering its second straight loss and its fifth setback in seven games.
The Cardinals held a 4-3 lead when Angel Pagan opened the San Francisco sixth with a single off starter Adam Wainwright (2-5). Pagan went to third on a double by Belt and then scored the tying run on a sacrifice fly by Emmanuel Burriss.
Belt doubled home Buster Posey in the seventh and the Giants added another run in the inning when Pagan raced home on a fielder's choice grounder by Charlie Culberson.
Matt Cain (3-2) collected the win despite allowing four runs in six innings. Santiago Casilla struck out one in a perfect ninth for his ninth save.
'SNL': 'Anchorman 2' cast, One Direction sing 'Afternoon Delight' [VIDEO]
Trader Joe's: Car crashes into Long Island store, injuring 11