Miami starter Trevor Rogers pitched 5 1/3 innings of one-run ball. Rogers (2-4) allowed five hits, struck out eight and hit a batter.
A day after leaving early because of stomach discomfort, Avisail Garcia singled twice for the Marlins, who snapped a five-game home skid.
''I think we have a great team here with the right pieces to compete,'' Aguilar said. ''You guys are going to see it. You guys are going to see that we are positive and stay together. At the end of the season we're going to be in a good place.''
Solo homers from Aguilar and Soler and Anderson's two-run shot against Milwaukee starter Eric Lauer in the fourth helped the Marlins erase a 1-0 deficit. Aguilar's and Soler's blasts started the inning, while Anderson connected after Jesus Sanchez reached on a two-out single.
''It's kind of what we were expecting, barrels, balls in the gap, baserunners on the move,'' Anderson said.
The Marlins padded their lead in the sixth on Miguel Rojas' two-run double and a fielder's choice by Garrett Cooper that scored Rojas from third. Garcia also raced home from second after Milwaukee second baseman Luis Urias' fielding error on Anderson's grounder.
There was a brief delay in the inning for a rules review as the umpiring crew needed verification of the count during Sanchez's plate appearance. Home plate umpire Bill Welke also ejected Marlins hitting coach Marcus Thames before Sanchez completed his turn.
''If you really watch that play, he didn't really swing, but it kind of looks like he does if you're not watching him with that move,'' Marlins manager Don Mattingly said of the pitch to Sanchez that forced the review. ''We've seen it enough, but when you look at it in real time, you're like, `It kind of looks a little funny, right?' And then they just got the count mixed up.''
Lauer (3-1) was lifted after five innings. The left-hander allowed four runs, six hits and struck out seven.
''He made bad pitches and they made him pay for it,'' Milwaukee manager Craig Counsell said. ''Not with singles but homers. If you look at all three pitches, they were pitches he didn't put where he wanted to. It was the middle of their lineup and they put good swings on it.''
Willy Adames gave Milwaukee an early advantage with his solo blast in the first. Adames drove Rogers' fastball over the wall in left for his ninth homer.
Hunter Renfroe tied Adames for the team home run lead with a two-run shot off Miami reliever Dylan Floro in the eighth.
MAY TO HIS LIKING
After hitting only one homer in April, Aguilar already has gone deep four times the first two weeks of May. Aguilar also has homered at home in consecutive games. Last season, Aguilar hit 13 homers on the road before his first home shot against the Los Angeles Dodgers on July 7.
''Stay positive, for me, that's what it's all about,'' Aguilar said. ''Just go out there and compete.''
Former Marlins pitcher Livan Hernandez threw the ceremonial first pitch to teammate Charles Johnson before the game. The retired pitcher and catcher were members of the Marlins' 1997 World Series championship team, which is being celebrated in the weekend series. Hernandez was voted World Series MVP after his two victories against Cleveland.
Brewers: RHP Jandel Gustave experienced right hamstring tightness during his one-inning of relief in the sixth. ... OF Andrew McCutchen (COVID-19 injured list) could return for the next homestand that begins Monday provided he clears the required protocols, Counsell said.
Marlins: Cooper left after his sixth inning at bat because of right knee contusion.
RHP Brandon Woodruff (3-2, 5.97) will start the series finale for the Brewers on Sunday and the Marlins will start RHP Elieser Hernandez (2-2, 6.37).
More AP MLB: https://apnews.com/hub/MLB and https://twitter.com/AP-Sports
Copyright 2022 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.