Cain (6-2) gave up a run on five hits and was lifted only after issuing his second walk of the game to Starlin Castro leading off the ninth inning.
"He's been so consistent and we needed it today because their guy was throwing the ball well," said Giants manager Bruce Bochy.
Ryan Theriot and Melky Cabrera singled and scored in San Francisco's two-run sixth inning. The Giants won the opener of this four-game series 4-3 on Friday after Madison Bumgarner took a shutout into the ninth inning. They have won five of six overall.
Matt Garza (2-4) lost his third start in a row despite allowing just five hits and a walk while striking out six in six innings. He is winless (0-3) in his last five outings.
"He did a nice job. Once again, we just couldn't muster anything against the starting pitcher again," said Chicago manager Dale Sveum. "Same old thing. It's just unbelievable how we have a hard time scoring against starting pitchers."
DeJesus homered for the Cubs, but they had just five hits.
Buster Posey's two-out single in the first inning was the only Giants hit until Brandon Crawford stroked a double with one down in the fifth.
Crawford was stranded on base, but the Giants took a 2-1 lead in the sixth with a rally sparked by back-to-back singles from Theriot and Cabrera to start the inning.
Earlier, DeJesus gave the Cubs a 1-0 lead in the fourth with his second homer of the season, a two-out blast to center. Tony Campana had led off the inning with a single, but was thrown out by Posey trying to steal second.
The teams wore replica uniforms from 1912, pre-game announcements were made using a megaphone and only organ music was played throughout. Other touches in the turn-back-the-century game included: a vintage look to the scoreboard, which didn't show any video; roving barber shop quartets outside the stadium; ushers, guards and grounds crew wearing period costumes and 5-cent peanuts.
For more on the Giants head over to McCovey Chronicles.