New York Mets relief pitcher Jeurys Familia, right, embraces catcher...

New York Mets relief pitcher Jeurys Familia, right, embraces catcher Travis d'Arnaud (18) after they defeated the Philadelphia Phillies 5-3 in a baseball game, Saturday, Oct. 1, 2016, in Philadelphia. Credit: AP / Laurence Kesterson

PHILADELPHIA — Every step took something out of the Mets. Every day brought a new hurdle, a new calamity, a new set of parameters to overcome.

But for six weeks, they stood in defiance of fear and fate and history, holding out until redemption finally arrived. It came Saturday, in a 5-3 victory over the Phillies, one that officially secured the Mets’ grip on the top wild-card spot in the National League.

For just the second time ever, this franchise pockmarked by promise unfulfilled has backed up an appearance in the postseason with another.

“Last year, going in, we were so excited at the end that we got into the playoffs for the first time in so long,” said Mets manager Terry Collins, the sting of Champagne still fresh. “But right now, this was hard.”

Michael Conforto entered into a slide in leftfield to track down Aaron Altherr’s broken-bat bloop. Closer Jeurys Familia raised his right hand and thrusted it toward the sky. Catcher Travis d’Arnaud clutched him tight.

In an instant, they found themselves awash in a sea of blue, their teammates mobbing them in front of the mound.

“I looked up at the sky and thought ‘thank God,’ ” shortstop Asdrubal Cabrera said. “Thank God again for the opportunity to be in the postseason.”

Few had expected this on Aug. 19, when they stood at 60-62, 5 1⁄2 games out of the wild-card race. From the field to the front office, the Mets found themselves choking back thoughts of expectations unmet. Because of attrition, these Mets bear only a passing resemblance to the crew that won the pennant a season ago, when they were driven by the adrenaline and the novelty of their first playoff run since 2006.

Still, Wednesday at Citi Field, they will host either the Giants or the Cardinals, the two rivals they ultimately outlasted in a dogfight that frayed their roster and tested their resolve.

“This one, we had to claw,” Collins said. “We had to claw and scratch and fight, deal with a lot of stuff that made it tough. This is why you play, to enjoy this kind of celebration.”

A year ago, the Mets surged past the Nationals in early September and captured the NL East title, seven games ahead of Washington. This year, the promise of postseason play did not come until a gray afternoon on the first of October, the penultimate game of a season spent in perpetual crisis.

“It’s great to see the team this year accomplish as much as it did with as many obstacles placed in its path,” said general manager Sandy Alderson, whose job involved clearing away those obstacles.

Little had gone according to plan for the Mets, defending champions of the National League, and misfortune made that magic feel like ancient history.

Matt Harvey, Jacob deGrom and Steven Matz have been lost to season-ending surgery, leaving three-fifths of a vaunted starting rotation in tatters. At one point, half of the Mets’ Opening Day lineup landed on the disabled list, their hopes for October flickering.

A year ago, David Wright returned from injury just in time for a pennant run. This year, his season ended long ago because of surgery, the team captain’s presence was a celebratory group text message.

Yet, the Mets filled the void, clinching a wild-card berth on the backs of players who wouldn’t have been uniform had it not been for circumstances. Thus, the players behind a six-week surge were the same ones to cap it with a flurry.

Jose Reyes, given a second chance only because Wright went down, knocked in a run. He has since become the heartbeat of the only team willing to sign him after his arrest for domestic violence.

“Thank you for bringing me back!” Reyes said, his arms thrown around Collins, in an embrace through their sweat and their tears.

Rookie T.J. Rivera, once undrafted and overlooked, knocked in a run. He had been left unprotected in the Rule 5 draft. On Wednesday, he’ll be starting at second base in the playoffs.

James Loney, who filled in at first base for Lucas Duda most of the season, bashed a two-run homer to put the Mets ahead, 4-2. He extended both of his arms skyward as the ball cleared the rightfield fence, then dropped his bat like a microphone.

“In that moment, there’s just a lot of emotion going on at that time,” Loney said. “You know how big the game is. Time has gone by so fast since a few months ago when I first arrived here. This is what you play for.”

Cabrera, with a banged-up knee that should have kept him on the disabled list, tacked on an insurance run with a flare single to right in the ninth.

Bartolo Colon (15-8), expected by now to be in the bullpen, picked up the victory by holding the Phillies to two runs in five innings, on Ryan Howard’s two-run homer.

If the Mets advance to the NLDS, the 43-year-old will front a rotation that has been saved by Robert Gsellman and Seth Lugo, rookies who struggled at Triple-A Las Vegas only to thrive when thrown into the fire of a race.

“This year was much tougher,” Colon said through a translator. “We had a lot of people that were injured. It was hard just to get here to play just this one game we’re going to play right now.”

Familia slammed the door for his 51st save. With that, warts and bumps and bruises and all, the Mets began a celebration that fit their ascent. This was no wild party from a year ago, but an almost reserved affair, a one-day break from creaking joints, inflamed tendons, and weary minds.

They broke out the goggles and cracked open bottles of Brut and Budweiser. They locked arms and jumped together, sticking out smartphones for selfies, all to document the end of an arduous journey.

In waves, they emerged from around the corner to douse Collins.

“I’m so excited,” said Cabrera, whose superb play through a knee injury has turned him into a leader in the clubhouse. “A lot of people didn’t think that we were going to be here. But we did it. We worked together, and that’s the key.”

At the end, the Mets had reached the point where will would not be enough. They needed the breaks of a soft schedule and rivals to fade. But mostly, they needed discipline to keep pushing, to pull themselves out the wilderness.

Since Aug. 20, when they began their arduous climb from two games under .500, the Mets are 27-12. In that span, their .692 winning percentage is the best in baseball, even as they’ve lost players along the way.

“We’ve played unbelievable baseball,” said Reyes, whose belief in the Mets was unflinching. “We never got down. We knew what we could do with this group of guys here.”

Newsday LogoSUBSCRIBEUnlimited Digital AccessOnly 25¢for 5 months
ACT NOWSALE ENDS SOON | CANCEL ANYTIME