Carmelo Anthony and Kristaps Porzingis had the Garden buzzing with a dizzying shooting display at the start of the game. But the building went silent just before halftime.

Anthony fell to floor and stayed down for a while. He turned his ankle stepping on referee Steve Anderson’s foot as he was running back on defense. He went to the locker room, got re-taped and started the second half, but lasted only 19 seconds.

The Knicks had to finish the game without Anthony — who exited with a sprained right ankle and Porzingis, who fouled out down the stretch. But the Knicks finished off the Celtics, 120-114, for their sixth win in eight games and had the Garden rocking at the end.

“It was a good win,” Derek Fisher said. “Definitely every guy who touched the floor helped us in some way. It was a good team effort.”

They played spirited basketball late and got big contributions from several players and improved to 20-20 on the season.

Porzingis made his first five shots and finished 10-for-18 with 26 points, but he fouled out with 2:44 to go. Arron Afflalo scored 20 of his 24 after Anthony left, including 10 in the fourth. Jerian Grant added 16. He hit four huge free throws in the final 31.4 seconds. Robin Lopez and Derrick Williams each had 15.

“It was a good win,” Fisher said. “Definitely every guy who touched the floor helped us in some way. It was a good team effort.”

Isaiah Thomas led all scorers with 34 points. Jae Crowder added 21 for Boston (19-19).

Anthony started 4-for-4, and ended up 7-for-10 with 17 points in 19 minutes. He played just one possession after halftime. When Robin Lopez looked to pass him the ball, Anthony waved him off and went to the bench.

He told a trainer, “I can’t push off it.” Anthony missed the Dec. 23 game in Cleveland with a right-ankle sprain.

Fisher hopes Anthony can play Wednesday but said it likely would be a game-time decision.

The Knicks, who led by 14 in the first half, were up 59-51 when Anthony left. They didn’t lose the lead until Evan Turner layup made it 95-93 with 6:58 left. A Jared Sullinger three-point play with 5:12 to go made it 102-99 Boston.

But the Knicks scored seven consecutive points, capped by a Porzingis’ jumper that made it 106-102 with 3:38 left. Those were Porzingis’ last points. He picked up his sixth foul when he hit Crowder who was attempting a three-pointer.

Crowder, who hit a three-pointer on the prior trip, made two foul shots to give Boston a 107-106 lead.

The Knicks regained the lead on the next trip on a Lopez hook shot. Then after a stop, Williams’ dunk in transition put the Knicks up 110-107 with 1:53 remaining.

After the two teams exchanged baskets on the next four possessions, the Knicks were clinging to a 114-113 lead. Grant was fouled and made both free throws to give the Knicks a 116-113 lead.

On the ensuing possession, Lopez blocked Thomas inside and Grant was fouled. He put the Knicks ahead by five with two free throws with 17.7 seconds remaining.

It was a gutsy effort for the Knicks to pull this one out and pull into a tie with the Celtics for ninth place in the East. But Fisher downplayed the importance of this game considering there is still half a season left.

“We haven’t dramatized a January game,” Fisher said. “I think if we could get to a point where, regardless of what the game may mean later, that we approach it with a particular mindset, to me that gives us a better chance to set a standard that we can sustain.

“We don’t want to be a team that gets more or less excited based on opponents and who they are and what happened last time. We’ve been somewhat OK in that category but we still have to keep pushing to get better.”

The Knicks have been playing their best ball of the season lately, and came out looking like a supremely confident team. Their defense wasn’t solid at the start, but their offense was nearly perfect.

They opened up hitting eight of their first 10 shots, and scored 26 points less than eight minutes into the game. The Knicks finished the quarter with 36 points and led by nine.

Porzingis and Anthony combined for 28 points — one more than the Celtics in the first quarter — and were 11-for-14 from the field.

The Knicks extended it to 55-41 in the second after an Anthony jump shot with 3:46 left. They scored just four points the rest of the quarter, but still held a 59-49 lead at the half.

“We have conversations at times about who we want to become,” Fisher said. “We’re trying to strive for being a really consistently good team night in and night out that regardless of who we’re playing, can meet a certain standard of performance that gives us a chance to win every night.”