''That one inning, it just got contagious,'' Giants manager Bruce Bochy said.
McAllister (3-1) retired 12 in a row before Michael Morse led off the fifth with a single to center. Morse advanced to third on Brandon Crawford's one-out single and scored on Gregor Blanco's pinch-hit single that came on a first-pitch fastball.
''Coming off the bench, it's not that easy to do,'' Blanco said. ''In that situation to get a pinch hit and drive one in ... you just got to be aggressive.''
Angel Pagan had a sacrifice fly before Pence's two-out hit gave the Giants a 4-3 lead.
McAllister left after Brandon Belt struck out to end the inning. He allowed five hits, struck out six and walked one after winning his previous three starts.
Buster Posey added a solo homer in the sixth as San Francisco earned its third consecutive win. Posey, who won the NL MVP award in 2012, went 1 for 3 and is batting .103 (4 for 39) over his last 13 games.
''I was happy for Buster,'' Bochy said. ''You go through these tough streaks and it's not easy.''
Giants starter Tim Lincecum lasted just 4 2-3 innings, but managed to lower his ERA to 5.96. He was charged with three runs, two earned, and nine hits.
''We did a really good job of making (Lincecum) work,'' Cleveland manager Terry Francona said. ''We just weren't able to get that one more hit to tack on.''
Lincecum has pitched just 25 2-3 innings in five starts in his first season since he signed a $35 million, two-year contract over the winter.
''I had my game plan. I just wasn't executing it,'' Lincecum said. ''That kind of exacerbated the feeling of hopelessness, I guess. Well, not hopelessness, but just things aren't going right. Fix that tomorrow.''
Romo got three outs for his sixth save in six chances as San Francisco's bullpen lowered its MLB-best home ERA to 0.45 in 11 games.
''Very impressive,'' Bochy said. ''They won the game for us today with the job they did.''
Bochy went out of his way to praise Gutierrez for striking out Yan Gomes with the bases loaded to end the fifth inning.
Cleveland scored in the first, third and fifth to build a 3-0 lead. Kipnis singled in Bourn in the first and drove in Swisher with a grounder in the third. Swisher doubled home Bourn in the fifth.
Saturday marked the 257th straight regular-season sellout at AT&T Park, matching the National League record set by the Philadelphia Phillies from July 7, 2009 to Aug. 5, 2012. Up next on the MLB sellout streak list is the Indians, who sold out Jacobs Field 455 times from June 12, 1995 to April 2, 2001.
NOTES: The Giants have now started off interleague play with two consecutive wins against the Indians after going 6-14 in 2013, the second-worst mark in MLB. ... McAllister registered his first career hit in the second inning with a single to right field. ... Giants Hall of Famer Willie Mays helped escort 3-year-old Cody Harrington to the mound to throw out the ceremonial first pitch. ... Right-handers Ryan Vogelsong (0-1, 7.71 ERA) of San Francisco and Danny Salazar (0-3, 7.85 ERA) of Cleveland enter Sunday's series finale in search of their first win of the year.