Garrett (9-6) tossed six innings, allowing four hits, striking out seven and walking two. David Robertson followed with a scoreless inning, Andrew Nardi worked out of an eighth-inning jam, and Tanner Scott finished for his eighth save in 11 opportunities.
Miami took a 1-0 lead in the fifth when Jesus Sanchez led off with a single, then was awarded second when first baseman Carlos Santana stumbled into the dugout catching a foul pop. Xavier Edwards' two-out single to left scored Sanchez.
The Marlins made it 2-0 in the seventh when Bryan De La Cruz doubled with one out off Andrew Chafin. Bryse Wilson took over on the mound, and Garrett Hampson lined an RBI double to left.
Milwaukee got the leadoff batter on in the ninth when Tyrone Taylor reached on a throwing error by third baseman Jake Burger, but Scott retired three straight.
The Brewers threatened in the eighth when William Contreras greeted Nardi with a single and Santana reached on an infield single that Nardi couldn't handle. However, Willy Adames bounced into a double play and Josh Donaldson struck out.
Milwaukee's Colin Rea (5-6), who came on in the second, allowed one run on four hits in 4 2/3 innings. He walked one and fanned three.
The Brewers (81-64) retained their four-game lead in the National League Central over the Chicago Cubs (78-69), who lost 7-3 at Colorado.
Miami (75-71), which had dropped the first two games of the four-game series that concludes Thursday, is a half-game behind the Cincinnati Reds (76-71) and the Arizona Diamondbacks (76-71) for the final NL wild-card spot. The San Francisco Giants are also 75-71.
Milwaukee also threatened in the fifth when Victor Caratini reached on an error and Sal Frelick singled with no outs. However, Garrett fanned Joey Wiemer and Andruw Monasterio, then got Contreras on a bouncer to short.
Hard-throwing Brewers reliever Trevor McGill, making his first major league start after 93 relief appearances, tossed a nine-pitch scoreless first inning as an opener before giving way to Rea.
Marlins center fielder Jazz Chisholm Jr. left in the fourth inning after unsuccessfully trying to beat out a double-play grounder. The team announced he was dealing with right knee discomfort.
—Field Level Media