NEW YORK — Don’t tell the Philadelphia Phillies that late September games don’t matter to teams not in contention.

The Phillies battled the New York Mets at every opportunity and had the NL East rivals just two-outs from a fourth consecutive loss on two different occasions, but the young Philadelphia bullpen was unable to complete the task.

Jose Reyes hit a tying two-run homer in the ninth inning and Asdrubal Cabrera hit a three-run drive in an 11th-inning comeback to lift the Mets to a dramatic 9-8 win over the Phillies on Thursday night that kept the Mets tied for the NL wild-card lead.

“This was the toughest loss of the season,” Mackanin added. “Our guys did a great job offensively. We should have had them. We just made a lot of bad pitches and let them right back in.”

The Mets used 27 players, including 10 pitchers, to win a struggle that took 4 hours, 23 minutes.

“That’s the thing about September,” Mackanin added. “They have a lefty for every righty I bring in and vice versa and that’s what makes it so difficult.”

Philadelphia went ahead 8-6 in the 11th when A.J. Ellis hit an RBI single off Jeurys Familia and Jim Henderson (2-2) walked Maikel Franco with the bases loaded.

Pinch-hitter Michael Conforto walked against Edubray Ramos (1-3) with one out in the bottom half, Reyes singled and Cabrera, who has been playing with a strained left knee tendon, sent a slider soaring to right, setting off a wild celebration. The Mets had been 0-63 this year when trailing after eight innings.

“As soon as I hit it, I knew the ball was going to be out,” Cabrera said.

A member of the Phillies staff was consoling Ramos at his locker after the game.

“He hung a slider,” Mackanin said. “Just a bad pitch.”

The extra frames were needed because the struggles of closer Jeanmar Gomez continued. Gomez came into the game having allowed six earned runs over his last three appearances and fell behind Reyes in blowing his sixth blown save of the season. New York trailed 6-4 before pinch-hitter Brandon Nimmo singled off Gomez leading off the ninth and Reyes sent a changeup over the right-field wall with one out.

“The last two weeks have been really tough on me,” Gomez said.

Mackanin feels that his young relievers can use this game as a learning experience.

“I think that the learning experience is that, against a team like this, or any major league team, you can’t make mistakes, you got to throw quality pitches,” he said. “If you do, you’re going to be successful and if you don’t, you’re going to get hurt.”

Starter Adam Morgan allowed three earned runs in five innings of work. Phillies starters have allowed three earned runs or fewer in 19 consecutive starts.

Cameron Rupp and Ryan Howard homered on consecutive pitches in the fifth inning to give the Phillies a 3-2 lead. Howard’s homer was his 47th against the Mets, tops among active players against the Mets.

TRAINER’S ROOM

Mets: LHP Steven Matz was scratched from his scheduled start on Friday because of continued discomfort in his left shoulder. He hasn’t pitched since Aug. 14.

Phillies: OF Tyler Goeddel was diagnosed with a concussion after getting hit by a Chris Beck pitch on Wednesday. . RHP Luis Garcia was hit on the right ankle by a sixth-inning line drive off the bat of James Loney. Garcia remained in the game.

HAIL, CESAR!

Phillies 2B Cesar Hernandez extended his career-best streak of consecutive games reaching base to 27 with a fourth-inning triple. It’s the longest on-base streak by a Phillie since Chase Utley reached in 28 straight in 2011.

UP NEXT

RHP Jeremy Hellickson (12-9) starts against the Mets for the fifth time this year on Friday. He has not allowed an earned run in his last 15 1/3 innings. RHP Gabriel Ynoa (1-0) will start in place of Matz.