Knicks center Isaiah Hartenstein defends a shot attempt by Cavaliers...

Knicks center Isaiah Hartenstein defends a shot attempt by Cavaliers guard Donovan Mitchell to seal the 105-103 win in an NBA game at Madison Square Garden on Tuesday. Credit: Kathleen Malone-Van Dyke

The Knicks were facing all sorts of problems as the clock started to tick down to the final seconds Tuesday night.

With a four-game losing streak and a double-digit lead disappearing, the Cleveland Cavaliers came down with the ball in the hands of Donovan Mitchell — adding in the potential to serve as one more reminder of the one who got away, the star who the team had failed to secure in the summer.

But as Mitchell slipped through the defense, made his way to the rim and rose for what would be the game-tying shot, Isaiah Hartenstein went up, too — extending his 7-foot frame straight up, getting a piece of the ball and forcing Mitchell to try to adjust in midair, the ball bouncing off the rim.

Mitchell, on the floor in pain, recovered the loose ball, and passed it to Evan Mobley, who misfired at the buzzer and the Knicks escaped with a desperately needed 105-103 victory at Madison Square Garden.

And while there may have been 18,612 fans screaming, all that Hartenstein heard was the voice in his head, the roar of coach Tom Thibodeau repeated through every practice, every timeout huddle and certainly now, in the final seconds.

“Yeah, Thibs screams it all the time — verticality, verticality,” Hartenstein said. “So that was going through my head just being vertical. No matter what he does, [if he tries] to dunk it, be vertical. If he tries to do what he did, tries to get a foul. My main thing was being vertical. If he made it, he made it. Go into overtime. Wasn’t trying to give him an and-one.”

Thibodeau laughed at the comment, but noted: “It was terrific, a monster play by him. He played a super game all around. So that was huge.”

The Knicks had played far better on this night than they had of late, defending better and most of the production had come from Julius Randle. He was switched onto Mitchell on that final drive and against the shifty guard he managed to steer him to the help, where Hartenstein was waiting.

“I know he wants to go stepback left and obviously I don’t wanna give up the three,” Randle said. “But just trying to get into him, force him to his right. And he took the drive to the rim and Isaiah just did a great job of using his verticality.”

Much of the work that Randle did was on the other end, where he provided a lift the team needed all night long. He drained five three-point field goals in the opening period, scoring 17 of his 36 points. But with the eight three-pointers he had on the night, the Cavaliers’ defense tried to take it away and he then muscled his way inside, setting a tone for the team in need of one.

And when the game seemed on the verge of falling apart, a double-digit fourth-quarter lead fading away, Randle grabbed a rebound with nearly the entire Cavaliers team surrounding him. He pump-faked and rose, drawing contract and converting the layup and the foul shot with 4:39 left, flexing for the crowd. The flex may have been for the fans, but really, Randle lifted the Knicks on his shoulders.

“I was talking a little trash to Luke Walton,” Randle said. “He was my coach in L.A., so I was talking a little trash to him, let him know he’s too small, too.”

“If you put a tally in the win column, you’re always thinking you’re improving,” Jalen Brunson said. “The best thing about this game, it wasn’t the cleanest, it wasn’t the smoothest, but we found a way to grind it out and get a win. It’s easy to win games when everyone’s clicking, and the ball is going in the hoop, but to win games when things aren’t going your way, this is a good steppingstone for us.”

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