MIAMI (AP) -- For a team that overcame an 11-31 start, a five-run deficit was nothing.
"I don't think we're surprised at what we're doing," closer Joe Borowski said. "But I'm sure everybody else is shocked."
The previous record for most games under .500, before going over .500 was 18 games, set by the Devil Rays in 2004. Tampa Bay was 10–28 through May 19, but rebounded to go over .500 on June 26, before finishing 70–91.
Joe Borchard's three-run homer capped a six-run sixth inning against the Diamondbacks, who have lost six in a row despite leading in each of the past five games.
With four consecutive victories, the Marlins (69-68) have a winning record for the first time. They were 11-31 on May 21.
Florida, which has the youngest team and lowest payroll in the major leagues, is two games behind San Diego, the NL wild-card leader.
"It's incredible," Borchard said. "We're playing for something very important, and every single one of us wants it badly. Why not? We've got a shot at this thing."
The Diamondbacks, fading from the playoff picture, have lost 14 of 17 to fall nine games below .500 for the first time.
"It's a terrible time to go in a slump as a team," third baseman Chad Tracy said. "We pretty much have to win out the rest of the year to have a chance. I think everybody knows that."
Florida, starting a 10-game homestand following a weekend sweep at Milwaukee, trailed 4-0 after one inning and 5-0 after five.
"It looked like we were still in Milwaukee -- that's how bad we looked," Borowski said. "Before you knew it, we were leading 6-5."
Dan Uggla capped the scoring with a two-run homer, his 22nd, to break Jeff Conine's franchise record for RBI by a rookie with 81. Uggla also made a key play on the basepaths and twice robbed Arizona of hits with diving stops at second base.
"He showed in this game that he's able to do everything," manager Joe Girardi said.
Arizona's Enrique Gonzalez (3-7) allowed only one hit in the first five innings and then gave up six in the sixth. A key play came with two out, one run in and runners at first and second, when Josh Willingham hit a high-hopper to Tracy. Uggla, running from second to third, dodged the grounder as he ran past Tracy, who hesitated before throwing late to first.
"I didn't know which way to go, so I just stutter-stepped," Uggla said.
Three consecutive hits followed, including a two-run single by Mike Jacobs and Borchard's eighth homer. Diamondbacks manager Bob Melvin said the home run was the first hard-hit ball off Gonzalez.
"Up to that point, it's as well as he pitched all year," Melvin said.
Gonzalez lost his fifth consecutive decision and remained winless in his past nine starts.
Florida's often-shaky bullpen shut out Arizona over the final four innings. Randy Messenger (2-7), recalled before the game from Class A Jupiter, pitched a perfect sixth, and Borowski earned his 33rd save in 38 chances with a 1-2-3 ninth.
That gave the Diamondbacks their eighth consecutive road defeat.
"Obviously we stole that one from them," Uggla said.
Moehler, making a spot start with rookie right-hander Ricky Nolasco sidelined by a sore hamstring, allowed seven hits and five runs in five innings. Moehler's ERA in 17 starts this season rose to 6.95.
The right-hander nearly escaped the first inning without giving up a run, but the Marlins failed to turn a double play that would have ended the inning, which allowed Chris Young to score from third. Johnny Estrada followed with a two-run RBI single, and Conor Jackson doubled home two more runs.
The Marlins recalled right-hander Jose Garcia from Double-A Carolina, and Girardi said the team will likely add two more players Tuesday. ... Byrnes' 21 homers are a career high. He had 20 in 2004. ... Uggla broke the Marlins' rookie record of 79 RBI set by Conine in 1993, the team's first season. ... Arizona center fielder Young made a running catch on the warning track before slamming into the wall to rob Miguel Olivo of an extra-base hit.