Cain outdueled Cubs starter Matt Garza, who threw six innings, blanking the Giants outside of a two-run sixth inning that had San Francisco's game-tying and go-ahead run.
"[Cain]'s been so consistent, and we needed it today because their guy was throwing the ball really well," manager Bruce Bochy said. "[Garza] was tough on us, and we found a way to get it done. But Matty is amazing. He keeps going; he competes so well."
With one out in the bottom of the sixth, Aubrey Huff drew a bases-loaded walk to score Ryan Theriot and tie the game. Joaquin Arias followed by knocking in the go-ahead run with an RBI forceout.
Theriot and Melky Cabrera had led off the Giants' half of that inning with back-to-back singles, and after Buster Posey flied out to center, Angel Pagan beat out a grounder to third for an infield single to load the bases for Huff.
"We scratched and clawed and found a way to get a couple runs," Bochy said, comparing his team's effort to that of a 1912 lineup without much power hitting. "I thought this would be a close game, with the time of day we're playing and the two pitchers who were throwing. We had to do the little things, and we did, just enough to win the game."
In the game's most crucial at-bat, Garza and Huff battled to a 3-2 count, and the ensuing Garza fastball just missed the strike zone.
"It is what it is -- it's not my call," Garza said. "As soon as I released the ball, I tried to throw a strike, and I guess I missed a little bit and walked a guy. I'll just get ready for Milwaukee in five days. I'll keep attacking and going with it."
Huff, who got the start at first base, had been batting .160 this season entering the game, including going 2-for-17 in May, and Bochy said he was encouraged with his patience in drawing the walk.
"It was a great at-bat," Bochy said. "It was a close at-bat, and he took a close pitch. That at-bat was huge; we got a run in. That's what it takes to win a ballgame, do the little things like that."
Garza was pulled after striking out Brandon Crawford with the bases loaded to end the two-run sixth. Along with his two earned runs allowed, Garza gave up five hits and struck out six batters.
Cain's lone blemish came on a home run by David DeJesus in the fourth to give the Cubs the early lead.
"I tried to throw a two-seamer and I kind of cut it more to the middle of the plate than I would have liked to, and he put a great swing on it," Cain said.
Along with the retro uniforms and the adjusted scoreboard, barbershop quartets roved around outside the gates of the park, and ballpark staff wore 1912-era clothing.
"The way the guys looked in the uniforms, it was funny," Romo said, calling teammate Madison Bumgarner "Bum Ruth" and "The Great Bumbino." "It was overall a great atmosphere."
The game's old-school pitching also found its way to the mound in the delivery of Cain's first pitch, in which he used an extra-long, over-his-head windup.
"You'll have to watch the replay," Cain said with a smile. "I saw [Jake] Peavy do it. He would do that in San Diego, always throw the first pitch like that [when wearing retro uniforms]. You're kind of thinking, 'Well it's only one pitch, you might as well stay in character a little bit.'"