The Mets slashed the Brewers' lead to 5-4 on Buck's two-run single in the sixth.
Milwaukee scored in a key run in the sixth with Gallardo in the thick of things. After Schafer led off with a single, Gallardo executed a two-strike sacrifice bunt. Marcum fielded the ball cleanly but his throw was dropped by second-baseman Murphy, who was covering first. The ball skipped into right field, allowing Schafer to race around the bases and beat a throw to the plate.
The Mets cut the lead to 6-5 in the seventh on Marlon Byrd's sacrifice fly. Schafer's run-scoring double, his third hit of the game, put Milwaukee ahead 7-5.
Byrd's home run in the ninth pulled the Mets within a run, but Rodriguez struck out Kirk Nieuwenhuis to end the game.
Gallardo (7-8), who has been the subject of recent trade speculation, scattered six hits over six innings and allowed four earned runs, striking out six and walking three.
Gallardo gave up one hit through the first four innings before running into some trouble in the fifth and sixth.
"I think he started to get a little tired," said Lucroy, who drove in two runs. "I think he really threw well the first four innings. His last two he scuffled a little but for the most part it was a solid start and he gave us a chance to win. That's most important."
Brewers manager Ron Roenicke liked what he saw from Gallardo early in the game.
"Yovani started off really well then lost some command," Roenicke said.
Francisco Rodriguez recorded his eighth save of the season and 302nd of his career despite giving up the two-out solo home run to Byrd in the ninth.
NOTES: The Brewers and Mets each will have two representatives on the NL All-Star team. The Mets' David Wright will start at third base after winning fan balloting at the position. Teammate Matt Harvey was named to the squad's pitching staff. Brewers OF Carlos Gomez and SS Jean Segura were selected as reserves. ... Brewers OF Ryan Braun took batting practice on the field Saturday after taking swings in a batting cage on Friday. Braun has been sidelined about a month with a thumb injury. ... The Mets Ike Davis stole his first base of the season in the second inning.