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.

StoryAfflalo picks up slack when Melo leaves with injury

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. Anthony started the second half, but lasted only 19 seconds.

The Knicks had to finish without Anthony — who left with a sprained right ankle and Porzingis, who played just eight second-half minutes because of foul trouble and fouled out down the stretch. But the Knicks showed heart and fight and finished off the Celtics, 120-114, Tuesday night.

The Knicks, who led by 14 in the first half, brought the Garden crowd to its feet many times late with their spirited play. They got contributions from several players in crunch time, won for the sixth time in eight games and improved to 20-20 on the season.

advertisement | advertise on newsday

“Sometimes guys go down whether it’s injury or foul trouble,” Derek Fisher said. “You need guys to step up and make plays and help you win and not be afraid of the moment. We had a number of guys that stood up to that test.”

Arron Afflalo picked up the scoring with Anthony out and rookie Jerian Grant controlled the offense. They each scored 10 in the fourth.

“It was a great team win,” Anthony said. “Arron took over. Other guys came to play and Jerian stepped up big.”

Knicks videos

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.

“[I’m] a little sore,” Anthony said. “I tried to give it a go in that third quarter. I didn’t have no strength in it to try to push off and get out there and play.”

Anthony missed the Dec. 23 game in Cleveland after spraining the same ankle, but he said this feels different. Anthony hopes to play Wednesday night against the Nets, but if he can’t he expects to return Saturday in Memphis.

Porzingis made his first five shots and finished 10-for-18 with 26 points, but he fouled out with 2:44 to go. He picked up his sixth fouling Jae Crowder while the Celtics forward attempted a three-pointer. Crowder made two free throws to put Boston up 107-106.

“Extremely frustrating,” Porzingis said. “That’s a terrible feeling honestly to not be able to help the team. I’ve just got to be smarter in the future about fouling and not being able to be on the floor for the last two minutes.”

advertisement | advertise on newsday

Afflalo scored 20 of his 24 after Anthony left. Grant added 16 points and had six of his eight assists in the fourth, and hit four huge free throws in the final 31.4 seconds. Robin Lopez and Derrick Williams each had 15.

“Everybody stepped up, everybody was ready,” Porzingis said. “That’s teamwork and that’s why we got the win.”

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

The Knicks were up 59-51 when Anthony left and didn’t lose the lead until the fourth. The Celtics’ biggest lead was three.

After Crowder’s two free throws put Boston up one, the Knicks regained the lead on the next trip on a Lopez hook shot. They got a stop on the next trip, and Williams threw down a dunk in transition to put the Knicks up 110-107 with 1:53 remaining.

advertisement | advertise on newsday

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 five with two free throws with 17.7 seconds remaining.

“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.