Tim Hardaway Jr. of the Knicks hits a three-point shot...

Tim Hardaway Jr. of the Knicks hits a three-point shot late in the fourth quarter against Joe Ingles of the Jazz at Madison Square Garden on Wednesday, Nov. 15, 2017. Credit: Jim McIsaac

Tim Hardaway Jr. spent parts of the game waving his arms for the fans to get up and banging his chest to show he had heart. He definitely showed some Wednesday night.

All the Knicks did.

They were down 12 with under five minutes left in the third quarter, but the Knicks fought hard to pull out the 106-101 win over the Utah Jazz at Madison Square Garden.

Hardaway played huge in the victory that Courtney Lee called “a must win” after the Knicks blew a 23-point third-quarter lead and lost to the Cavaliers Monday. Hardaway played one of his best all-around games of the season, and finished with 26 points, six rebounds and six assists.

With the Knicks (8-6) looking sluggish for much of the game, they needed Hardaway’s energy throughout. But he seemed to have more than anyone else when it turned late.

Hardaway, who signed a four-year, $71 million contract over the summer to be a cornerstone player, scored 14 points in the fourth quarter, including the Knicks’ last seven points. He drilled a humongous three-pointer with 32.5 seconds left to give the Knicks a 102-98 lead. The Garden erupted, Hardaway shimmied, and Lee jumped on his back.

“It was awesome,” Hardaway said. “Those are the moments you live for; you live for and you dream of when you’re a kid. Come into a grand stadium like this and making game-winners, making go-ahead baskets and playing defense and giving the fans what they want.”

Hardaway made four foul shots in the final 19.8 to put it away.

The Knicks showed resilience by not only responding in this game, but coming back after the Cleveland meltdown.

After being outscored 43-25 in the fourth quarter by Cleveland, the Knicks outscored Utah 43-26 over the final 16:49 to pull out the victory. Their defense sparked the victory as they held the Jazz to 19 points in the final quarter.

“This was a must-win for us,” Lee said. “That game against the Cavs, we were up 23 in the third quarter and blew that lead. We pretty much dropped the ball that game. Just coming out here and getting down, that was our mindset that we had to win this game. Especially after that last game. What better way to get over that last game than to come out here and getting the win today.”

Kristaps Porzingis scored 22 points and grabbed eight rebounds. Lee finished with 19 points, but his hamstring cramped up in the fourth quarter and he got kneed in the back of his upper leg. Lee limped off, but he said he would be able to play Friday in Toronto.

Rookie Frank Ntilikina played the entire fourth quarter, scoring five points during the comeback and his defense continues to be impressive.

Rodney Hood’s 30 points off the bench led the Jazz (6-9). Donovan Mitchell, who the Knicks considered taking with the eighth pick, finished with 19. He scored just two in the second half and had a critical turnover after Hardaway’s three-pointer.

Down four, the Jazz went for a steal but when they couldn’t get it, Hardaway was intentionally fouled with 19.8 seconds to go. He made both to give the Knicks a 104-98 lead, and praised the team for showing fight.

“It says a lot,” Hardaway said. “The desire to win, not taking no for an answer, no excuses, and fighting through fatigue, fighting through adversity.”

The Knicks took their first lead after Hardaway scored on a fast-break layup to make it 94-93 with 4:04 left.

Porzingis then scored five straight, including a three-pointer with 2:20 left, to give the Knicks a 99-93 lead. They had a chance to extend it on the next possession, but Hardaway misfired on a long three-pointer, leading to a trey on the other end by Joe Ingles.

After Porzingis missed a three-point try, Ricky Rubio got in the paint and scored over Porzingis to bring Utah within 99-98 with 1:14 remaining. On the next possession, Hardaway Jr. drove and was blocked but Ntilikina got the rebound.

The rookie made a bad pass, and there was a scramble for the ball. Doug McDermott dove and passed it out and the Knicks maintained possession. Hardaway made up for his ill-advised three-pointer earlier and drilled the crucial three to put the Knicks up four.

“The problem was we did that twice before that,” Jeff Hornacek said. “Tim took one, KP took one, and it wasn’t in the flow of the offense, trying to get the dagger shots to end the game there. That’s where we have to grow as a team and realize that’s when you execute. Free throws are just as good. If you can take it inside and put pressure on them and get to the free-throw line that’s an easy way to finish out games, too. So we’ll work on that. we’ll get better at it.

“Tim’s next one, that was big. We needed that one.”

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