It was around this time last year that the Mets, carried on the back of their dominant pitching but otherwise struggling to stay afloat, began searching for the player who could spark their offense. Someone who could fill a hole in the outfield and make them a contender.

It took a few weeks and a botched trade, but eventually, Yoenis Cespedes came to Flushing with his big smile, his neon- green compression sleeve and his penchant for saving this team from the brink of oblivion.

One National League pennant later, he’s still doing it. In one of the largest comebacks in franchise history, the Mets, led by a host of players but Cespedes especially, overcame a six-run deficit to defeat the Marlins, 8-6, on Monday at Citi Field.

They erased a troubling performance by Matt Harvey, who didn’t make it out of the fourth inning, and maintained the momentum gained from their four-game sweep of the Cubs. All this, a week after sports pundits and more than a few fans had declared this season all but over.

“Real big,” Terry Collins said of the win. “There can’t be a letdown. We talked to the team before the Cubs series and we said we have a lot of games . . . We’ve got to grind it out for 11 days [until the All-Star break] and if we do, we’ll be OK.”

The Mets, who trailed 6-0 in the fourth, scored a run in the bottom of the inning on Travis d’Arnaud’s homer and another in the fifth on Curtis Granderson’s blast. They then scored two each in the sixth, seventh and eighth.

With the score tied at 6 and two outs in the eighth, Cespedes blasted Fernando Rodney’s fastball into the gap in right-center to drive in d’Arnaud and Neil Walker, trailing right behind d’Arnaud as the catcher waved his arms wildly for Walker to go for home.

In doing so, the Mets registered the fourth-biggest comeback in team history.

“I think even before those two home runs, we still had that positive attitude in the dugout that there was a lot of game left to be played,” Cespedes said. “After those two home runs, I think it gave us the strength that we needed to push through.”

Cespedes, who extended his hitting streak to eight games, also scored the tying run in the seventh. With David Phelps in to pitch, Walker led off with a walk and moved to third on Cespedes’ double. James Loney’s RBI groundout and Wilmer Flores’ sacrifice fly made it 6-6.

The Mets’ bullpen pitched 5 1⁄3 innings of scoreless relief, capped by Jeurys Familia’s MLB-leading 29th save in 29 tries. “I’ve looked around the league, and I don’t know anybody else who’s got that,’’ Collins said in reference to a possible All-Star berth.

It all tempered a series of brutal innings by Harvey, who after the game said he still is looking into an issue with his mechanics.

Five of the six runs he allowed were earned, and the unearned run came when he botched a throw to the plate. With the bases loaded in the fourth, Martin Prado hit a soft bouncer to Harvey, who threw it away to give the Marlins a 4-0 lead. Christian Yelich then singled to plate two more. Harvey gave up 11 hits, walked none and struck out four.

“It wasn’t fun being out there the way it was, but it was obviously fun watching the team battle back like that,” said Harvey, who hasn’t won since May 30. “It showed a lot of character and a lot of heart, and unfortunately, I couldn’t get it done when I was out there, but we got to keep pushing.”

All-Star headache. Collins, who will manage the National League All-Star team, said making the selections for the final roster — which will be revealed Tuesday — has been anything but easy. “There are numerous guys who are going to be left off who are deserving to be on the team,” he said. “I was told it was not much fun, and they are correct.”