Carmelo Anthony of the New York Knicks reacts after making...

Carmelo Anthony of the New York Knicks reacts after making a basket against the San Antonio Spurs late in the second half at Madison Square Garden on Sunday, Feb. 12, 2017. Credit: Jim McIsaac

If this was Carmelo Anthony’s final home game as a Knick, he can say he led his team to its best win of the season.

Anthony scored 25 points and hit three clutch baskets in the final 2:45 to lift the Knicks to a 94-90 victory over the mighty Spurs on Sunday at Madison Square Garden.

“I always love those moments, especially in a big game like this going up against a team like San Antonio,” Anthony said. “You embrace those moments and those challenges.”

It was only the Knicks’ seventh win in the last 27 games and easily their most impressive of this underachieving season. After losing the first four games of this homestand, they closed it out impressively.

The Knicks (23-33) have one more game before the All-Star break, Wednesday against the Thunder in Oklahoma City. They next play in Cleveland on Feb. 23, the date of the trade deadline.

Anthony has been the subject of numerous trade rumors — the Knicks have spoken to the Cavaliers, Clippers and Celtics — but he has a no-trade clause and can veto any deal. He wouldn’t address whether he was thinking that this could have been his MSG finale in a Knicks uniform.

“Oh, come on, man,” Anthony said. “Don’t start that. Don’t start that.’’

It’s not just Anthony. The Knicks hope this game will set them on the right track and save their season. But they could be active at the deadline even if they can’t deal Anthony.

Anthony, who said Friday there is a “cloud” over the Knicks, didn’t play like someone worried about his future. He shot 9-for-21 overall but was 4-for-6 in the fourth quarter. With the Knicks leading 83-81, Anthony scored seven of their next nine points, including back-to-back jumpers that put the Knicks up 92-86 with 33.2 seconds left. He also moved past Charles Barkley into 25th place with 23,775 points.

“He’s a monster,” Spurs coach Gregg Popovich said.

Derrick Rose added 18 for the Knicks. Kristaps Porzingis had 16 points, seven rebounds and four blocks and Willy Hernangomez added 12 points and nine rebounds.

Kawhi Leonard led the Spurs (41-13) with 36 points and nine rebounds. LaMarcus Aldridge had 15 points and 10 rebounds.

The Knicks definitely approached this game differently from Friday night’s, when they gave up 131 points in a loss to the Nuggets. Jeff Hornacek said the starters should have been “embarrassed” after that performance. Before Sunday’s game, he said that if the Knicks are “not alert,” the Spurs could score 140 points.

Hornacek switched the starting lineup, moving Por zingis back to power forward and inserting Hernangomez at center. The move worked as well as all the video work because the Knicks played with the pride and passion they have lacked on so many nights, and they defended.

“It was all effort,” Rose said.

“I think the trust came out,” Hornacek said.

With the Knicks clinging to an 83-81 lead, Rose turned the ball over, but Courtney Lee broke up the fast-break opportunity, stole the ball back and threw it ahead to Anthony, whose three-pointer put the Knicks up five with 2:45 left. Anthony gave it right back, though, fouling Leonard on a three-pointer. He hit all three free throws.

After Hernangomez scored on a sweet reverse layup with 1:47 left, the Knicks needed a stop and got it, leading to a turnaround jumper by Anthony that made it 90-86. After another defensive stand, Anthony scored again to make it a six-point lead as the crowd erupted.

“It’s definitely a relief,” Anthony said. “I won’t say the cloud is gone in one day . . . But for us to come out here and get this win is definitely a relief from everything that’s going on.”

Anthony is looking forward to the All-Star break. It’s the first time in eight years that he won’t be going, but he could be a candidate to replace Kevin Love, whose All-Star status is in doubt because of a left knee injury. Anthony said he’d “consider it,” but he’s busy.

“I got plans,” he said. “I would love to just utilize this break and my body and my mind and just get away from everything. If they call me, I’d consider it. But I would love to utilize this break.”

DON'T MISS THIS LIMITED-TIME OFFER1 5 months for only $1Save on Unlimited Digital Access