The fans started heading for the exits with about a minute remaining in the game, but they could have left earlier. The Knicks’ offensive performance Tuesday night made a 10-point fourth-quarter deficit look insurmountable.

Those who stuck around booed as the final seconds wound down on the Knicks’ 97-89 loss to the Celtics at Madison Square Garden. It was their sixth setback in seven games and dropped the Knicks five games under .500 for the first time this season. They’re 23-28.

The Knicks shot just 37.8 percent from the field, misfiring on 51 of 82 attempts. The only starter to shoot 50 percent was Robin Lopez, who was 6-for-12 and had 17 points and 13 rebounds, including nine offensive boards.

Arron Afflalo led the Knicks with 18, but only seven came after the first quarter. Carmelo Anthony shot 4-for-16 and fouled out with 16 points, none in the fourth. Kristaps Porzingis was 4-for-11 with 10 points, and Langston Galloway went 0-for-4 and finished with one point.

“We couldn’t find a combination of guys that could sustain us on both ends,” Derek Fisher said. “We were searching.

“There aren’t excuses and explanations other than we’re just not getting the job done in terms of being able to go out and bring the game to our opponent. Right now teams have more guys who are able to impact the game.”

Porzingis struggled to find any rhythm and looked flat-footed on defense for the second straight game.

First-time All-Star Isaiah Thomas scored 20 for Boston (28-22). Jae Crowder and Tyler Zeller had 16 apiece, and Evan Turner 14.

The Knicks fell behind 81-70 with 9:07 left after a Kelly Olynyk three-pointer. But they charged back to get within 81-77 after back-to-back baskets by Derrick Williams and an Afflalo three-pointer. But the Knicks didn’t make a field goal for the next 4:24. Compounding matters was they couldn’t stop Boston, as Turner was getting open shots and Zeller was cleaning up misses.

The Celtics were up 93-83 when the Knicks finally ended their drought with a Porzingis runner with 3:13 left. The Knicks never got it under eight the rest of the way.

Before the game, Fisher said there’s been “slippage” in the Knicks’ focus lately as talk about them being good enough to make the playoffs has grown louder. The Knicks are in 10th place in an improved Eastern Conference, and there are 31 games remaining. So that talk, inside and outside the Knicks’ locker room, is premature.

But the Knicks showed some urgency at the outset, racing out to a 9-0 lead. They couldn’t sustain it during a first quarter that had no flow and 11 fouls, including one flagrant on Anthony and a technical on Fisher.

After all the dust settled, the Knicks led 22-21 after one. In the second, it was the Celtics who got off to a fast start, scoring the first eight points. The Knicks answered with a 18-6 run and took a 40-35 lead on an Afflalo foul shot with 3:47 to go in the half.

Afflalo led the Knicks with 13 points at halftime. Lopez had a big impact, scoring eight points. He had nine boards in the first half and all of them were offensive rebounds.

The Knicks didn’t lose the lead until Crowder drilled a three-pointer to make it 54-51 with 8:39 remaining in the third. The Celtics were 0-for-13 from three-point range before Crowder connected from deep.

The Celtics extended to 59-53 after their second three, by Thomas with 6:37 to go in the third. The Knicks regained the lead less than two minutes later on Lance Thomas’ jump shot that made it 62-60 with 4:45 left. But the Knicks ended the third very sloppily. They missed six of their last seven shots, committed four turnovers and trailed 70-65 after three. Afflalo had three turnovers in a 24-second stretch during that span.