"It was good for us to start off a long road trip on the right foot," said third baseman Casey McGehee, a member of the Brewers' 2011 playoff team. "Obviously, I've seen Yovani enough to know that you've got to come with your 'A' game, because he can shut down an offense with the best of them."
Marcell Ozuna, Garrett Jones and Giancarlo Stanton each homered off Gallardo, who was rocked for six runs -- five earned -- on nine hits in 3 2/3 innings. In seven previous starts against the Marlins, Gallardo went 5-0 with 1.12 ERA, including 2-0 last season, when Miami did not score against him in 14 1/3 innings.
"His stuff was a little elevated," said Stanton. " I would say his breaking pitches weren't as sharp or placed like he usually does. When a pitcher's not feeling their best, that's what you've got to do -- hop on it."
In taking the opener of the four-game series, the Marlins moved within three games of the Brewers and Braves, the two teams immediately ahead of them in the National League Wild Card chase. (The Braves lost to the Nationals, 2-1, on Monday night.)
The Brewers, who were 19 games above .500 at one point and led the NL Central for 150 consecutive days, have lost 12 of their last 13.
"They're not playing their best as of late, I noticed," Stanton said. "So we can't be the team that turns them back around. We've got to keep it up, and we've got three more."
The Marlins, just 4-14 at Miller Park since 2009, erased a one-run deficit by scoring three runs in the second. Ozuna opened with his 20th home run, a monster shot halfway up the scoreboard in straightaway center. Jones followed with his 14th homer, which went over the left-field wall. After Gallardo fanned Jarrod Saltalamacchia to become the Brewers' all-time leader in strikeouts, with 1,207, Adeiny Hechavarria singled, advanced on Brad Penny's sacrifice bunt and scored on Christian Yelich's single to center.
Stanton opened the third with his 37th homer, tying his previous season high, set in 2012. It was also the 154th of his career, tying Dan Uggla for the Marlins' all-time lead. Jones doubled in another run to make it 6-2.
Miami missed an opportunity to add on in the fourth, loading the bases with two outs, but Milwaukee reliever Marco Estrada struck out Ozuna to end the threat. Estrada prevented the Marlins from extending their lead with a 4 1/3 scoreless innings.
While Gallardo was unraveling, Penny was overcoming a rocky start with the help of three double plays and battled through six innings, his longest start since being called up from Triple-A New Orleans on Aug. 9.
"I'm a different guy now," said Penny, who sat out the 2013 season and pitched only in relief in 2012. "I can't go out there and overpower hitters, and I don't need to. Keep my pitch count down and get quick outs. Even with the three walks, I didn't throw a whole lot of pitches, because I got the ground-ball double plays after."
Most of the outs against Penny were ground balls to the left side of the infield.
"We hit every ball into the ground against him," said Brewers first baseman Mark Reynolds. " I don't know. He just kept throwing us in with the sinker. It was a frustrating night."
Penny, making his first start against the Brewers since 2008, was staked to a one-run lead in the first on an RBI single by McGehee, but the Brewers answered with a pair of runs in the bottom of the inning on an RBI double by Scooter Gennett and a run-scoring groundout by Jonathan Lucroy.
The Brewers added two runs in the eighth off A.J. Ramos on an RBI double by Carlos Gomez and a run-scoring infield single by Lucroy.
"We put together some great at-bats," Marlins manager Mike Redmond said. "Scored in the first and ended up giving up a couple of runs in the first inning, but after that we just kept adding on, and Brad did a good great job of shutting them down, getting some big double plays and giving us six solid innings."