The division-leading Pirates were prevented from achieving a milestone win and suffered their second loss in six contests. Pittsburgh's next victory will ensure its first winning season in 21 years.
Milwaukee snapped a five-game losing streak.
Pittsburgh sent Francisco Liriano to the mound in search of his fourth win in five starts, but he was shelled for seven runs on seven hits in just three innings.
Norichika Aoki and Carlos Gomez both singled off Liriano (15-7) to open the third and Lucroy delivered a ground-rule double that brought home Aoki and snapped a 2-2 tie.
Aramis Ramirez then came through with a two-run double and Milwaukee added two more runs on a ground out by Jeff Bianchi and a wild pitch thrown by Liriano.
Wily Peralta (9-14) earned the victory with a six-inning performance in which he gave up three runs on nine hits with six strikeouts.
The Pirates twice left the bases loaded and stranded 12 men overall.