The Giants trailed 6-5 coming into their final at-bat, but Francisco Peguero led off by clouting a score-tying homer off Huston Street (2-5).
That brought up Pence, who lined a single to center field to bring home the game-winning run.
The outfielder, obtained from Philadelphia in July 2012, was on the final year of his contract with free agency approaching. The San Francisco Chronicle reported the new deal to be worth $90 million.
Sergio Romo (5-8) picked up the win for the defending World Series- champion Giants (76-86).
Jedd Gyorko smacked a grand slam for San Diego (76-86).