The Marlins entered the night percentage points behind New York. But the Mets are now 67-83, to the Marlins' 66-85 mark.
Marlins rookie Jacob Turner had a tough-luck night, giving up six runs, with three earned in five innings.
Miami was charged with just one error, but there were several sloppy plays, which led to Turner logging a season-most 115 pitches.
"The way we played the first three innings, four innings, was embarrassing," Marlins manager Ozzie Guillen said. "If I was pitching in that game, I would fight with somebody."
Donovan Solano drove in two runs, including an RBI double in a two-run sixth inning.
In the fifth inning, Miami left fielder Justin Ruggiano removed himself with a right shoulder sprain he incurred after diving for Hairston's liner, which fell for an RBI triple.
After retiring Fred Lewis to open the first, the inning became unglued for Turner. The 21-year-old allowed three runs, with the big blast being Hairston's two-run homer.
"Obviously, it's a team game," Turner said. "It was a frustrating game. When guys got on base, they capitalized on it. I've got to make better pitches in those situations."
The Mets also caught a break when Daniel Murphy was ruled safe on an infield single to second. Replays showed Solano's throw beat Murphy by a half-step.
Murphy stole second and scored on Davis' RBI single, a sharp hop that skipped off the glove of Solano. Initially, it was ruled an error, but then changed to a single.
Hairston gave New York some cushion with his 18th homer.
Neither team played crisp baseball, but the Mets had more timely hits, and were able to avoid slipping into last place.
Both teams had higher expectations when the season began.
"Ozzie is a great friend of mine, played for me," Mets manager Terry Collins said. "The two of us sit here and shake our heads before the game going, 'Who would've thought it.' Especially when we saw each other in Spring Training, I looked at his club and said, 'They're going to be really tough to beat.'"
Nothing has gone according to plan this year for the Marlins, who are in danger of losing 90 games for the second straight season.
In the second inning, the Mets tacked on two more runs. A throwing error by Jose Reyes made both runs unearned. Josh Thole doubled, and he moved to third on Niese's grounder to short. Reyes tried to get Thole advancing, but his one-hop throw wasn't fielded cleanly by third baseman Gil Velazquez, who applied a tag too late. Niese ended up scoring on a wild pitch. Murphy added a sacrifice fly.
The Marlins were down five after two, but got on the board in the third inning. Velazquez singled and scored on Solano's single to right.
In the fifth inning, the Mets added another unearned run. The Marlins could have been out of the inning, but with Murphy -- who reached on a passed ball after striking out -- on second, Davis lined out to Reyes at short. Murphy was well off the bag, but Reyes didn't make an attempt to double him up at second. Hairston followed with his triple.
"He lost track of a lot of things today," Guillen said of Reyes. "He had a bad game mentally. The first game we've seen him do that. That happens. Hopefully, it won't happen the rest of the season. But I don't think he was there [mentally] much."
If the Marlins rebound and take the final two games in New York, they could still leave town out of the basement.
"We've played good baseball, but just got beat. Today was ugly," Guillen said. "We helped [Turner] to lose a game. We didn't help him to win a game. Hopefully, we can show up tomorrow and play better. It seemed like we had today off."