Cain (6-2) won his fifth straight start with the dominant outing, holding the Cubs to five hits and two walks. He struck out seven.
The right-hander threw 71 of his 117 pitches for strikes while lowering his ERA to 2.62.
The Giants, who took their second straight in a four-game series with the Cubs and won for the fifth time in six contests overall, erased a 1-0 deficit with two runs in the sixth, including a bases-loaded walk drawn by Aubrey Huff and an RBI groundout supplied by Joaquin Arias.
Matt Garza (2-4) was the loser for the Cubs, surrendering two runs on five hits in a six-inning effort.
David DeJesus socked a solo homer for Chicago's only run.
Selena Gomez drops F-bomb, walks off stage during Jingle Ball performance
Reindeer recovered after escaping from Santa during lighting ceremony