Now he's looking for a few more hits.
Pence has 34 RBIs and 37 hits with San Francisco. He is batting .233 with four homers in 41 games with the Giants.
"I need to get more hits is what that tells me," Pence said, "Make them pitch to (Buster) Posey with runners on."
Pence's third career grand slam capped a five-run third inning for the NL West-leading Giants, who won for the third time in four games and are 11-5 in their past 16.
Cain sparked the outburst with a leadoff walk and moved to second on Marco Scutaro's one-out infield single. After Pablo Sandoval singled to center to load the bases, Posey hit a grounder to third and Cain slid under Ryan Wheeler's throw on a close play to make it 1-0.
Pence followed with a long drive into the left-field stands for his 21st homer of the season.
"You can never walk the pitcher," Diamondbacks starter Tyler Skaggs said. "I thought they were good pitches but I ended up walking him and then the whole inning kind of exploded."
Cain (14-5) walked three in the first and stranded five runners over the first two innings.
The right-hander allowed four hits, walked a season-high five and also hit a batter. He was charged with one run and struck out two.
"That was a gutsy effort," Giants manager Bruce Bochy said. "It just got to a point where I had to go get him."
Cain failed to make it through six innings for the second time in his last three starts.
"I couldn't put away some guys like I wanted to," Cain said. "I got too fine with some pitches."
Reliever Santiago Casilla also drove in a run for the Giants, who remained 7 1/2 games ahead of Los Angeles with 18 games remaining. The Dodgers beat St. Louis 8-5 on Friday night.
Chris Johnson drove in both runs for the Diamondbacks, who stayed 4 1/2 games behind the Cardinals for the second wild-card spot. Skaggs (1-2) allowed five runs and five hits in four innings after lasting only three innings in his previous start against San Diego on Sept. 7.
"It's been unacceptable on my part the last two outings," the 21-year-old left-hander said. "It's almost been embarrassing."
Arizona left 15 men on base against seven Giants pitchers.
"We certainly had our opportunities," manager Kirk Gibson said. "A lot of plays we didn't play very well tonight. We made it harder on ourselves and we didn't capitalize on the opportunities we did have."
After putting the first two runners on three times in the first five innings, the Diamondbacks finally broke through in the sixth.
"That was a game-saving play," Bochy said. "If that ball gets down the line it's a different ballgame."
Casilla threaded a bases-loaded single into right field in the eighth for his first career hit, putting the Giants ahead 6-1.
"I think we were all kind of shocked he made contact," Bochy said. "He found a good place."
Johnson added an RBI single in the ninth for Arizona.
Sandoval, returning to the lineup after two days off, finished 3 for 4. . Cain threw 34 pitches in the first inning and 106 overall. . The roof at Chase Field was open during the game for the first time since June 9. . Diamondbacks LF Jason Kubel doubled off Angel Pagan at first in the seventh for his 13th outfield assist of the season, a new club record. ... Montero, who walked three times and was hit by a pitch, became the second Diamondbacks player to reach base four times without a hit in a nine-inning game. Luis Gonzalez accomplished the feat twice. ... Arizona's Double-A Mobile affiliate won its second straight Southern League championship series title Friday night and its rookie-level team in Missoula won the Pioneer League championship series. ... LHP Wade Miley, the second of three straight rookie southpaws, will take the mound for the Diamondbacks against veteran LHP Barry Zito. Zito is 5-8 in 19 career games against Arizona but 2-0 in three starts this year. ... The Diamondbacks will stage their first-ever alumni game after Saturday's game.