Updated

Hunter Pence clubbed his third career grand slam as the San Francisco Giants downed the Arizona Diamondbacks, 6-2, on Friday.

Buster Posey scored twice and knocked in a run and Santiago Casilla picked up his first career base hit and RBI for the Giants, who have won eight of their last 12.

Matt Cain (14-5) allowed one run on four hits over five-plus innings to pick up the win despite walking a season-high five batters.

Chris Johnson went 2-for-3 and drove in both runs for the Diamondbacks, who had won five of seven overall entering the game.

Tyler Skaggs (1-2) was pegged with the loss after giving up five runs on five hits over four innings.

"(Skaggs) made a mistake to Pence. That is the big one," D'backs manager Kirk Gibson said. "All the other stuff, that happens. He throws a high fastball right where you don't want to throw it. That was their big blow."

The Giants scored five in the third inning. Cain walked, moved to second on Marco Scutaro's single before taking third when Pablo Sandoval ripped a single up the middle. Posey then reached on a fielder's choice, scoring Cain.

Pence followed with a grand slam to give the Giants a 5-0 lead.

"(Pence) had a great at bat, he did battle back, got a pitch he could handle there and he smoked it," Giants manager Bruce Bochy said. "That's huge, we got one run in and to get a grand slam, that gives you a little cushion, which we needed."

Arizona loaded the bases with no outs in the sixth, but came away with just one run as Johnson scored Miguel Montero with a pinch-hit single.

Chris Young then ripped a line drive down the third base line, but Sandoval made a spectacular diving stab to save at least one run. Adam Eaton then grounded into a force out before Aaron Hill struck out to end the inning.

San Francisco added one more in the eighth to push it to 6-1. With the bases loaded, Casilla punched a single through the hole at first to score Posey.

The Diamondbacks added one in the ninth when Johnson dropped a single in right-center field to score Paul Goldschmidt.

Game Notes

The Giants are 21-10 over their last 31 games ... Since the All-Star break, San Francisco is an MLB-best 22-7 on the road ... Arizona went 2-for-16 with runners in scoring position and left 15 runners on base ... D'Backs left fielder Jason Kubel picked up his franchise-best 13th outfield assist of the season.