Pittsburgh lost for the fourth time in five outings and slipped a full game behind idle St. Louis at the top of the National League Central.
Gallardo (10-9) gave up six hits and a lone walk while striking out five. Brandon Kintzler threw two hitless innings of relief to finish off the shutout.
Lucroy singled in a run in the first and drove in Milwaukee's final run with a sacrifice fly in the eighth. Khris Davis had an RBI double in the second and Aramis Ramirez hit a solo homer in the fourth.
Gerrit Cole (6-7) suffered the loss, giving up three runs on 10 hits in 7 1/3 innings.