The New York Knicks battled from behind in Game 2 and came up big to come away with a 104-101 win over the 76ers, NewsdayTV's Steve Popper reports. Credit: Newsday

All season long, the Knicks have put the ball in the hands of Jalen Brunson and let him carry them, and he put together a season so magical that it was hard to imagine that there would come a time when he could not.

That time seemed to arrive Monday night. But somehow the magic suddenly was conjured again in the final seconds.

Somehow — and it’s hard to explain — the Knicks scored eight points in the final 27.4 seconds and escaped with a 104-101 win over the shocked Philadelphia 76ers to take a 2-0 lead in the best-of-seven series. The series now shifts to Philadelphia for Game 3 on Thursday.

Brunson had misfired all night, with open shots clanking wildly and defenders draping him at every turn. So with the game seemingly out of reach — down five, why not? — he fired up a three-pointer in front of the 76ers’ bench that seemed to hit the outside of the rim before bouncing up and in to cut the deficit to two with 27.4 seconds to play.

Then, as the 76ers inbounded with the Knicks swarming Tyrese Maxey, he fell to the floor and Josh Hart ripped the ball out of his hands.

Donte DiVincenzo misfired on a three-pointer, but Isaiah Hartenstein grabbed the offensive rebound and fired it out to DiVincenzo, who didn’t miss this time. His three-pointer gave the Knicks the lead with 13.1 seconds remaining.

As chants of “de-fense!” echoed through the Garden, the Knicks got a stop as Hartenstein altered Maxey’s driving shot and OG Anunoby hit a pair of free throws with 6.6 seconds left. But they still needed one more miss, and when Joel Embiid misfired on a buzzer-beating attempt from three-point range, they finally could exhale.

Hart, who played all 48 minutes, raced along the baseline, hugging John Starks and Carmelo Anthony, along with any other Knicks fan who got in his way.

“Not exactly sure what happened right before that, but JB got a good look at a three, was able to knock that down,” Hart said. “At that point, probably 15 seconds left, we’re down two, got to be as physical as we can be, try to get the steal. And that’s what we did. JB did a great job denying. Then we were able to get that steal, kick it out, [Donte] was able to hit that shot. It was crazy, it was hectic. But at that point we’ve got nothing to lose. We’ve got to be as physical as we can. And it panned out.”

“I felt like [expletive],” DiVincenzo said. “I missed the first one. To be completely honest, I was hoping Isaiah got the offensive rebound, just cause I knew I was gonna get a second opportunity. We practice that every day: dagger threes and second- chance threes . . . I just got my feet set, trusted the work I put in and thankfully it went down.”

Brunson followed an 8-for-26 performance in Game 1 with an 8-for-29 shooting night as Kelly Oubre, Nic Batum and Maxey took turns on him. But the only shot he likely will remember is the last one, the one that went in to give him 24 points.

For the Knicks to survive, it took unlikely efforts up and down the roster, and just like Game 1, those other pieces delivered. Hart had 19 points in the first half and finished with 21 points and 15 rebounds. DiVincenzo had 19 points.

“We don’t give up,” Hartenstein said. “I think there’s a lot of teams that probably would have gave up in that situation. I mean, it starts with Thibs. He always believes no game is ever safe. He kind of instilled it in us, so it starts with him and the whole team just buys in. So we had a belief that we’ll come back and it worked out.”

The mystery of who would play for Philadelphia was solved at game time as Maxey and Embiid, who were listed as questionable throughout the day, were in the starting lineup. Maxey showed no ill effects of what the team called an illness, finishing with 35 points in 44 minutes. Embiid added 34 points and 10 rebounds.

Hartenstein had 14 points, all in the second half, and he and Mitchell Robinson kept Embiid from grabbing a single rebound in the second half.

“We should be 2-0. So we’re good,’’ Embiid said. “We’re going to win this series. We’re going to win this. We know what we’ve got to fix. We did a better job today, so we’re going to fix it. But we’re the better team and we’re gonna keep fighting.”