Gallardo (11-9) extended his unbeaten streak to six starts, during which he has gone 3-0. The right-hander yielded three hits and a walk while striking out six.
Brandon Kintzler followed up with a scoreless eighth and Jim Henderson secured the win with his 24th save.
Jeff Bianchi provided a go-ahead two-run single in the seventh as the Brewers took the rubber match of a three-game series.
Chicago's Justin Grimm (0-1) absorbed the loss after Scott Baker -- making his first major-league start since having elbow ligament replacement surgery in 2011 -- had blanked the Brewers on two hits over five scoreless innings.
Junior Lake homered for the Cubs.
N.J. man wakes up from 10-hour sleep with knife in back
Exploding whale video goes viral on Internet