NEW YORK -- Two full games, plus two more innings. A total of 561 pitches. And when it was finally (FINALLY!) over, the worst team in baseball had its 17th win of the season.

The Miami Marlins sure worked hard for this one.

In the longest major league game in more than three years, Adeiny Hechavarria hit an RBI single in the 20th inning and Miami outlasted the New York Mets 2-1 on Saturday, well after Matt Harvey left with lower back tightness following another stingy start.

"It was amazing," winning pitcher Kevin Slowey said. "It was an amazing game."

Steve Cishek retired Daniel Murphy on a fly ball to the left-field warning track for the final out of a game that took 6 hours, 25 minutes. It started 5½ hours before the Belmont Stakes -- about 13 miles away -- and still ended around an hour after winner Palace Malice crossed the finish line.

The last big league game to go as long also involved the Mets, according to STATS. It came when they beat St. Louis 2-1 in 20 innings on April 17, 2010.

It was the longest game by far in the history of Citi Field, which opened in 2009, and it matched the longest in Marlins history -- a 7-6 loss to the Cardinals in 20 innings on April 27, 2003.

"You play 20 innings, you've got to win that game," Marlins manager Mike Redmond said.

Harvey and Miami's prized rookie, Jose Fernandez, hooked up in a pitchers' duel early. And when neither punchless lineup could break a 1-all tie, the only saving grace for both teams was that neither had played since Wednesday and both had fresh arms in the bullpen.

By the 13th inning, the game had been turned over to a pair of starters: Slowey and Shaun Marcum for the Mets. Both were originally scheduled to start Saturday before getting skipped when Friday night's game was rained out.

A scattered crowd of 20,338 had dwindled perhaps into the hundreds by the time the stadium sound system played Chuck Berry's "No Particular Place To Go" not long after the 14th-inning stretch.

Some of the fans who remained chanted "Let's Go Home!" as the Mets came to bat in the 17th. But it took three more innings to decide this one, and it was Miami that came out on top.

"The whole team spirit was up," said Rob Brantly, who caught the entire game and finished with four hits. "We were still having fun in the dugout and still cracking jokes and keeping the energy high. ... Still had enough energy to string some hits together and get that run."

Placido Polanco, Brantly and Hechavarria hit consecutive singles with one out in the 20th off Marcum (0-7), who had retired 16 in a row to that point. He gave up five hits in eight stellar innings with seven strikeouts and no walks.

"I definitely wasn't expecting to pitch eight innings," Marcum said. "I wasn't tired. That pitch to Hechavarria was a pretty good pitch. He went down and got it."

Slowey (2-5) was just as tough. He struck out eight and walked none in seven shutout innings before Cishek got three straight outs for his sixth save.

Inept at the plate, the Mets went 0-for-19 with runners in scoring position -- a team record. They stranded 22 on the bases.

After taking all three games from the Mets at home last weekend for their first sweep of the season, the last-place Marlins improved to 7-3 against New York this year. They are 10-41 against everyone else.

"I think moving forward, guys can kind of reach back in their mind and say, that 20-inning game we didn't give up. If we're not going to give up now, we're not giving up," Slowey said.

On his last pitch in the seventh, Harvey said he felt a little tightness in his right hip where it meets his lower back. He singled in the bottom half and seemed to run somewhat gingerly to second base on an inning-ending groundout.

He warmed up for the eighth, but then there was a mass meeting on the mound that included a trainer, manager Terry Collins and the entire Mets infield.

Harvey finally gave up the ball -- reluctantly, it appeared -- and walked to the dugout. Brandon Lyon was given all the time he needed to get loose, then he wriggled out of a jam to keep the score tied.