NEW YORK — Despite helping his team engineer a remarkable comeback from 25 points down against the Boston Celtics at Madison Square Garden on Thursday night, star forward Julius Randle wasn’t happy.

Midway through the fourth quarter, Randle made a layup and, as he ran back to the other end of the court, gave the sellout crowd a thumbs down as they cheered his name.

When asked after the game what message he was trying to get across to the fans, Randle didn’t mince his words.

“Shut the f— up,” he said.

In response to a follow-up question about whether this was because of the boos the Knicks heard throughout the first two-plus quarters of Thursday’s win, when the Celtics thoroughly outplayed them, Randle said, “You saw that. You saw what was going on out there.”

Randle’s thumbs-down gesture was reminiscent of what then-New York Mets shortstop Javier Baez did this summer. After hitting a home run, Baez gave the crowd at Citi Field a pair of thumbs down, saying later it was in response to the fans’ treatment of him and his teammates throughout the season.

For Randle, the gesture was a continuation of comments he made the day before at the team’s practice facility when he was asked about the negativity that has surrounded his play this season.

“I really don’t give a f— what anybody has to say, to be honest,” Randle said. “I’m out there playing. Nobody knows the game out there better than I do, compared to what everybody has to say.

“So I really don’t give a s—. I just go out there and play.”

Last season was a charmed one for both Randle and the Knicks. He became an All-Star and All-NBA player for the first time and won the NBA’s Most Improved Player award en route to leading the Knicks to 41 wins and the fourth seed in the Eastern Conference playoffs. He set career highs in several categories, including scoring, rebounding, assists, 3-point field goal percentage and free throw percentage, helping New York break a seven-year playoff drought. Knicks coach Tom Thibodeau also won the league’s Coach of the Year award for a second time.

This year, though, has been far different. Randle’s production has dipped, most notably his 3-point shooting, which is down more than 8 percent from last season. And while the Knicks had virtually the same record at this time last season, the circumstances surrounding it are far different.

Last season, the Knicks entered the season with no expectations and exceeded all of them. This year, they entered the season with expectations built upon last year’s fourth-place finish in the East, but they find themselves sitting 10th in the conference — the final play-in tournament spot — after Thursday’s dramatic victory.

After Celtics star Jayson Tatum hit a game-tying jumper over the Knicks’ RJ Barrett with 1.5 seconds left, Barrett delivered the win on a banked 3-pointer at the buzzer.

Randle, who gave several clipped answers before explaining his actions during the game, was asked if the win was special.

“I don’t know,” Randle said. “It was special for our team. But we kept battling. Obviously don’t want to get in a hole, but us as a team, we kept battling, stay with it and found a way to win the game.”

Randle has always played with his heart on his sleeve, and that passion has bubbled up at other times this season, including against the crosstown rival Brooklyn Nets earlier this season, when he and Thibodeau were frustrated over how he was being officiated in a Knicks loss.

“He puts emotion into everything he does,” said Evan Fournier, who poured in a career-high 41 points against his former team and admitted he didn’t see the gestures Randle made toward the crowd.

“He probably wasn’t happy about [the booing]. Honestly, no big deal. If I were him, playing hard as hell and [playing] well … when you give everything you have into something and you give so much into something and it doesn’t work out or you’re being called out, it’s frustrating.

“But it’s the business we’re in. And Julius is the image of the franchise. He’s the star player, so of course he’s going to get more criticism. And I think he understands that.”