The Marlins, who also committed two costly errors along with a botched appeal play, fell 4 1/2 games behind the Pirates in the race for the second NL Wild Card spot, and three games behind Atlanta and Milwaukee, which had lost 13 of its last 14 games. Pittsburgh defeated Philadelphia and Atlanta beat Washington on Wednesday.
"We were sloppy tonight," Marlins manager Mike Redmond said. "It wasn't our best defensive showing, no doubt. ... This time of year, every mistake will cost you, and it did tonight."
After six scoreless innings, the Marlins finally got to Peralta when Marcell Ozuna opened the seventh with his 22nd home run, sending a 3-2 pitch the opposite way to right for his third homer of the series to cut the lead to 2-1.
Miami then loaded the bases on one-out singles by Jarrod Saltalamacchia and Adeiny Hechavarria. Pinch-hitter Justin Bour then just missed a home run, flying out to the warning track in deep right-center. Zach Duke replaced Peralta and walked Christian Yelich, but Jonathan Broxton came on and retired Donovan Solano on a flyout to right.
"It was a two-strike changeup, it faded away a little bit just off the end of the bat," Bour said. "Not enough. With two strikes, I was just trying to put the barrel on the ball. Close, but not close enough."
The Brewers combined long ball and small ball for two runs in the bottom of the inning to make it 4-1. Matt Clark hit the second pitch from reliever Sam Dyson over the right-field wall for his first career home run -- the first allowed by Dyson since Sept. 16 of last season, a span of 26 games. Jean Segura then beat out a dribbler in front of the plate and took second on a throwing error by Saltalamacchia. Segura advanced on Logan Schaefer's groundout to first and then scored when Carlos Gomez beat out another dribbler back to Dyson.
"We were still one big hit from making it a game or getting ourselves out in front," Redmond said. "Bour just missed and almost hit that ball out. Other than that, though, we were quiet. Peralta did a nice job keeping us in check. Ozuna did a nice job and it looked like that might get us going, but other than that, that was it."
One night after giving up two homers in ninth inning, Brewers closer Francisco Rodriguez allowed just a single in a scoreless frame to preserve the win for Peralta.
"Yeah, we did get some breaks today," Brewers manager Ron Roenicke said. "It's been a long time. That helped. But we really played a good game today."
Jarred Cosart, who had won his last four decisions, allowed two runs -- one earned -- on four hits over six innings.
The Brewers pushed across an unearned run in the third for a 1-0 lead. Segura opened with a bouncer to short, but reached and continued on to second when Hechavarria's throw sailed wildly past first baseman Garrett Jones.
The Marlins thought Segura missed first base on the turn, but when Cosart stepped off the rubber and made the appeal throw to first, Segura stole third on the play. Peralta followed with a sacrifice fly to right.
"As a starter, errors are going to happen, things are going to happen, weird stuff like that's going to happen, but it was my mistake by lobbing the ball over there and giving Segura a base and then allowing the pitcher to get an RBI," Cosart said.
Milwaukee made it 2-0 in the fourth when Cosart sandwiched a pair of walks around a single to load the bases. Clark followed with a sacrifice fly.
"You can't walk two guys in a Major League baseball game and expect for the other team not to score and then expect to have a chance to win," Cosart said. "So, if I could have anything back, it would be those two walks and maybe come out of the game 1-1 and the whole dynamic of the game changes going forward."
Yelich prevented a run in the first with a perfect throw from left field to the plate to cut down Jonathan Lucroy, who was attempting to score from second on Aramis Ramirez's single.