Knicks forward Michael Beasley, left, and forward Kristaps Porzingis react...

Knicks forward Michael Beasley, left, and forward Kristaps Porzingis react against the Hawks at Madison Square Garden on Sunday, Dec. 10, 2017. Credit: Kathleen Malone-Van Dyke

So what do you do for an encore after you lose to the worst team in basketball?

You find a way to beat the second-worst.

After an ugly night in Chicago, the Knicks returned home to the relative safety of Madison Square Garden and hung on to defeat the Atlanta Hawks, 111-107, on Sunday night.

The Knicks (13-13) eked out the victory despite fouls by Ron Baker and Jarrett Jack that led to five Atlanta points from free throws in the final 1:40. Kristaps Porzingis came up big with 30 points — his first 30-point game since Nov. 11 — eight rebounds and three blocked shots. He put the game away by hitting two free throws with three seconds left.

“I think we did a terrible job of making that game more interesting than what it should have been down the stretch,” said Jack, who finished with a season-high 19 points and shot 7-for-11, including a foul-line jumper with 29 seconds left that gave the Knicks a five-point lead.

With No. 2 scorer Tim Hardaway Jr. out until at least Dec. 19 with a leg injury, the Knicks need others to help shoulder the offensive load, and the reserves stepped up.

Doug McDermott had a season-high 23 points and shot 9-for-13. Baker had nine points and four assists in a season-high 31 minutes. Frank Ntilikina scored eight points, all in the final quarter.

The Knicks utilized a small lineup throughout the fourth quarter with Baker and Ntilikina in the backcourt.

“The bench stepped up tonight,” coach Jeff Hornacek said. “That was huge for Doug; for us too . . . He attacked the basket. I thought we did a better job of getting downhill, getting down the lane and then kicking out. With the combination of Jarrett and Ron, Frank did some of that and Doug drove in there, so when we keep it spread out and we drive it, it gives a few more opportunities to shoot threes and get to the basket and maybe even get fouled.”

Jack lives in Atlanta in the offseason and said he wanted to have something to brag about when he goes to the gym.

“I’ve been a little passive with my offense. Trying to sacrifice that,” he said. “We had a number of guys that were rolling offensively early on in the season. I thought it was like a no-brainer for me to sacrifice that for the betterment of the group, betterment of everybody. But you know, we got Tim out . . . So I try to step in and be aggressive. I was able to knock down a couple shots early, man, was able to get in a pretty good rhythm.”

Dennis Schröder led Atlanta (6-20) with 21 points and Ersan Ilyasova added 20.

Hornacek showed some frustration before the game when asked about the up-and-down nature of his team.

“It’s consistency,” he said. “We’ve done a great job this year playing with effort, playing hard all the time. But then you kind of fall into sections where you have a quarter or a half here and there of not having that full energy. We have to be consistent every single night, and that’s pretty much it.

“Look at when we were winning games. The effort was there the whole 48 minutes. [Saturday] night was a road game which you really need to [because] sometimes you’re not on top of your game. At home, you can still win some games, but on the road, you have to be on top of your game.”

The Knicks need to pile up the wins during the next couple of weeks while their schedule remains relatively soft. In their next four games, they play three very beatable opponents: the Lakers, Nets and Hornets.

Things really get tough beginning on Dec. 27, when the Knicks will play 16 of 20 games on the road. They are 1-8 away from home.

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