Buster Posey delivered a one-out double in the top of the ninth and scored when Pence drove a pitch into the right-field gap, giving the Giants what seemed like an insurance run and an 8-5 lead.
But San Francisco ended up needing it when Jeremy Affeldt allowed run-scoring singles to Alexi Amarista and Chris Denorfia in the bottom of the frame.
Clay Hensley notched his third save when he struck out pinch-hitter Mark Kotsay to end the game and hand the Giants a series-clinching victory.
Jose Mijares (1-0) earned the victory.
Joaquin Arias went 3-for-5 with a solo homer and three RBI, while Posey finished 3-for-4 with a sacrifice fly for San Francisco, which retained a one-half-game lead over the Los Angeles Dodgers atop the National League West.
San Diego's Brad Brach (1-3) was the loser in relief of starter Eric Stults, who gave up five runs over six innings.
Chase Headley went 2-for-4 with a three-run homer for the Padres.
Millions of Getty images now available for free via embed tool
Kim Kardashian, Kanye West reportedly set wedding date