The Giants (31-51) scored 10 consecutive runs to come back from a 3-1 deficit and stretch their winning streak to four games. Pence had three singles and a hit by pitch to drive in five runs within five innings.
San Francisco scored three runs in the fourth inning and five in the sixth. It scored at least one run in seven innings.
The Pirates (37-43) left 10 men on base.
Giants right-hander Johnny Cueto (6-7) allowed three runs and seven hits in seven innings but got the better of Pirates right-hander Gerrit Cole.
Cole (6-7) failed to extend his winning streak to four games, allowing seven runs and 10 hits in 5 1/3 innings. His night began to unravel in the fourth inning before the Giants ballooned their lead to 10-3 in the sixth and 11-3 on a Pence single in the seventh.
Trailing 3-1 after the first inning, the Giants scored one run on a Pence single in the third and three in the fourth to take a 5-3 lead.
After Cole forced Brandon Crawford to fly out and Jae-Gyun Hwang to strike out to begin the fourth, he allowed three straight singles to load the bases. Joe Panik singled to right to tie it at 3 before Pence hit San Francisco's fifth consecutive single to add two runs.
San Francisco had a promising start before its explosive fourth. Denard Span led off the first inning by driving an 0-1 pitch into the stands beyond right field.
That lead didn't last long, though.
Josh Bell grounded into a fielder's choice, which scored Adam Frazier from third in the bottom of the first. John Jaso followed with a double off the right-field wall, driving in Josh Harrison, before Bell scored on a sacrifice fly from Gregory Polanco to make it 3-1.
NOTES: The Pirates went with the same lineup they used to beat the Tampa Bay Rays 4-0 on Thursday. The lone change was RHP Gerrit Cole starting and batting ninth. ... Pirates INF David Freese did not start for a second consecutive game. He is hitting .249 with 25 RBIs in 59 games this season. ... Giants C Buster Posey, who hit cleanup, returned after sitting behind C Nick Hundley on Wednesday. RF Hunter Pence was also reinserted into the lineup and hit in front of Posey. ... Denard Span started in center field and batted leadoff for San Francisco. OF Gorkys Hernandez started in his place Wednesday.