Updated

The Miami Marlins were in prime position to rally from a 6-1 deficit to the Milwaukee Brewers before a baserunning error proved costly.

Following an RBI single by Donovan Solano in the seventh, Miami's third straight run-scoring single, the Marlins trailed 6-4 and could have had no outs and the bases loaded. But Bryan Petersen overran second base on the play, anticipating Greg Dobbs being sent home by third base coach Joe Espada.

Espada held up Dobbs, Petersen was tagged for the first out of the inning, and the comeback hopes fell short as the Marlins went on to lose 8-5 to the surging Brewers on Wednesday night.

"We find another way to lose and that's number 935 in we find a way to lose," Marlins manager Ozzie Guillen said.

Jose Reyes hit a sacrifice fly and Giancarlo Stanton flew out to end the inning following Petersen's blunder.

"An aggressive mistake I guess," Petersen said. "It's one of those interesting plays in baseball when you think one thing and another thing happens."

Meanwhile, the Brewers are doing their best to stay in the National League wild card race. Rickie Weeks homered twice and tied a career-high driving in four runs to help Wily Peralta (1-0) win his first major league start.

"The biggest thing is we keep seeing the standings and trying to creep up on everybody, but at the same time we have some pretty good professionals in here who want to come in and try to keep winning ball games," Weeks said. "We kind of know what is at stake right now. We feel pretty good about ourselves."

Corey Hart also homered and drove in four runs for Milwaukee, which has won 13 of 16 to climb within 6 1/2 games of St. Louis for the second NL wild card spot.

"Hopefully we continue this for a little bit, but if we do it could be fun," Brewers manager Ron Roenicke said. "We're playing really good ball."

Milwaukee (67-69) also trails the Los Angeles Dodgers and Pittsburgh — Atlanta currently leads the wild card standings — and moved within two games of .500 for the first time since May 4 when they were 12-14.

"It's good to hear, it will be better when we are .500," Roenicke said.

Peralta pitched six innings, allowing three runs and five hits. The 23-year old right-hander struck out three and walked four.

"You're always happy when you win," Peralta said. "I just followed (catcher Martin Maldonado) and I felt comfortable."

Weeks hit a pair of two-run homers for his sixth career multihomer game and first since hitting two on July 18, 2010 at Atlanta. He is hitting .484 (15 for 31) with two home runs and six RBIs during a seven-game hitting streak.

"I'm feeling good right now," Weeks said.

Nathan Eovaldi (4-11) surrendered the first home run to Weeks to left field in the third inning. Eovaldi allowed two runs and struck out four in five innings.

"I threw the ball pretty well," Eovaldi said. "I felt I attached the zone pretty well. Later on, I struggled finishing the curve ball, left it up when I needed to bury it."

Weeks' second home run to left field came off Tom Koehler, also making his major league debut, to give the Brewers a 4-1 lead in the seventh. Hart followed with his 27th home run, a two-run shot to left-center.

Hart hit a two-run double to cap the scoring for the Brewers before John Axford pitched the ninth for his 25th save in 33 chances.

NOTES: Brewers 3B Aramis Ramirez came out of the game in the ninth inning with a slight back strain, which he aggravated during his at-bat in the seventh. "I'll be alright," Ramirez said. ... Peralta went 7-11 with a 4.66 ERA in 28 starts at Triple-A Nashville. ... Brewers SS Alex Gonzalez (torn ACL in right knee) has not played since May 5, but has not been ruled out for the season. "I don't know, that would be a question mark of whether Alex will be ready," Roenicke said. "He is ahead of schedule with what he's doing so I don't want to say no because I don't know. He's probably got an appointment in a couple weeks. If Dr. Raasch says he's ready to go then we'll have to rethink what we're doing." ... Miami RHP Josh Johnson (7-11, 3.86 ERA) will start Thursday's series finale against RHP Marco Estrada (2-5, 3.85 ERA).