Pence struck again with one out in the sixth after Pablo Sandoval and Posey lashed one-out singles off Neal Cotts. Pence's slicing drive off the right-field wall scored Sandoval.
The Rangers averted a shutout in the seventh inning against right-hander Sergio Romo, who retired the first two hitters he faced. Adrian Beltre singled and pinch-runner Brandon Snyder scored on Jim Adduci's double to deep center field.
Andres Torres padded San Francisco's lead with a two-run, seventh-inning homer off Johan Yan, who pitched five hitless innings in his previous five appearances. Brandon Allen added an RBI single in the ninth.
Cain lasted five innings, the longest outing by a Giant this spring. He surrendered two hits while striking out two.
"I felt confident throwing whatever I wanted," Cain said.
While Derek Lowe made a good first impression for the Rangers, rookie left-hander Joe Ortiz continues to enjoy an excellent spring. Ortiz has still not allowed a run after retiring the side in order in the third inning. Ortiz has pitched seven innings this spring and has allowed three hits and a walk while striking out seven.
"He has been doing a good job," manager Ron Washington said. "He keeps the ball down and keeps getting one ground ball after another."
Up next: San Francisco will confront both of Ohio's Major League teams in split-squad games Saturday. The Giants will entertain the Cincinnati Reds in a 1:05 p.m. PT encounter at Scottsdale Stadium, then will confront the Cleveland Indians at Goodyear beginning at 7:05 p.m. Madison Bumgarner, coming off a four-inning, one-hit shutout effort against Texas last Monday, will face Cincinnati. Right-hander Chris Heston, who already has been optioned to Triple-A, will start the night game against Cleveland.
Chris Haft is a reporter for MLB.com. This story was not subject to the approval of Major League Baseball or its clubs.