PHOENIX -- Some big hits and a risky move that paid off finally brought an end to the San Francisco Giants' losing streak.
Pence's homer into the eating area of the restaurant in the second deck in left field to help Brandon McCarthy become the season's first 10-game loser.
"That ball was one of the longest home runs I've seen in a long time," Giants manager Bruce Bochy said.
Ryan Vogelsong (5-3) gave up four runs in five innings but got his first victory in four starts and only the second for the NL West-leading Giants in 11 games
"There's two ways to get out of this thing," Vogelsong said. "Either come out and swing the bats and score a bunch of runs or throw a bunch of zeroes. We know which one happened."
Aaron Hill, a .500 career hitter against Vogelsong, singled, doubled and drove two runs for the Diamondbacks.
McCarthy (1-10) allowed five runs and 10 hits in five innings. The 10 hits matched a season high.
After blowing his previous two opportunities, Sergio Romo escaped trouble in a scoreless ninth for his 21st save in 25 tries. With runners at second and third, two outs and Paul Goldschmidt coming to bat, Bochy went to the mound to make sure Romo knew what to do. Hill would be the next batter.
The choice was to go after Goldschmidt.
"It's a tough call," Bochy said. "You're going against the book a little bit."
Romo gave up a one-out, pinch-hit double to Roger Kieschnick, then Didi Gregorius beat out an infield single. The runners moved to second and third when Gerardo Parra grounded out, bringing up Goldschmidt.
The Arizona slugger hit it hard to right, where Pence tracked it down.
"He (Goldschmidt) is 4 for 0 and Hilly is 0 for 6 (against Romo)," Arizona manager Kirk Gibson said. "I am surprised they didn't pitch around him the whole series. ... They got away with it. `'
Romo's pitch was very hittable.
"He might have got away with that pitch, but he got him out," Bochy said, "and that's a big out for us to end this losing streak."
Pablo Sandoval singled three times with an RBI and scored a run for San Francisco.
Colvin singled in two runs in the first and drove in another with a ground out after Brandon Crawford tripled to lead off the fifth.
San Francisco first baseman Michael Morse left the game in the bottom of the fifth inning with back tightness after an awkward swing at the plate. Morse said it was nothing serious. Bochy said he'd give him Sunday off and see what happens after that.
Pence got the Giants started with a one-out single up the middle in the first. Buster Posey followed with a single, then Sandoval singled Pence home, with Posey taking third when left fielder David Peralta booted the ball. Crawford drew a two-out walk to load the bases, then Colvin's two-run double made it 3-0.
Arizona got two in the fifth to make it a one-run game before Pence's homer provided a two-run cushion.
The Giants called up top 2B prospect Joe Panik from Triple-A Fresno. He made his major league debut as a pinch hitter in the eighth and walked. ... To make room for Panik, San Francisco optioned OF Juan Perez to Fresno. ... In the finale of the series on Sunday, the Giants send Madison Bumgarner (8-4, 2.85 ERA) to the mound against Arizona's Mike Bolsinger (1-2, 5.70). ... McCarthy has more RBIs (3) than wins (1). ... McCarthy's lone victory came on May 3 at San Diego. He also gave up 10 hits, but in seven innings, against the Dodgers on April 11. ... The Giants stranded 10 runners, Arizona eight.