NBA

Lin picks up third win vs. Knicks as Melo 3 waved off

Carmelo Anthony scored 45 points Thursday, but the points that could have won the game got wiped away by an intentional foul and referee Scott Foster’s whistle.

Anthony’s 3-point miracle shot that could have forced overtime or even won it was waved off with five seconds left as the Knicks lost again to the Rockets in a foul-plagued, controversial 109-106 decision at the Garden. It was fourth straight home loss for the 3-5 Knicks.

It gave Jeremy Lin his third straight win over the Knicks since departing for Houston, as the Rockets swept both games last season. The same defensive problems existed Thursday night. Lin finished with 21 points in 29 minutes, and the Knicks lost despite Anthony and Andrea Bargnani (24 points) combining for 69 points.

The Knicks, who started last season 10-0 at home, still are looking to rediscover the magic formula at the Garden.

“It was a tough one to lose, especially with the effort we put forth,’’ Anthony said. “We have to get over this hump at home. I am at a loss of words.’’

Anthony could have been the hero in Lin’s second return to the Garden with a benefit of a call. For Anthony, it was a similar situation to the game in Chicago on Halloween when he missed a 3-pointer in the closing seconds in the Knicks’ 81-80 loss to the Bulls.

This time, trailing by three points, Anthony drained the 3-pointer, but it didn’t count as referee Foster ruled James Harden intentionally fouled Anthony far enough before the release. After getting hacked, Anthony threw up a prayer, and it sailed through the net as the Garden erupted.

Instead of a potential four-point play, it was ruled a non-shooting foul. With the Rockets in the penalty, Anthony had just two free throws. Coach Mike Woodson screamed for a review, Anthony argued vehemently, shaking his head, and the fans booed. Anthony made both free throws to cut the deficit to 107-106 with 5.0 seconds left, but they fell short.

“It was a tough call, but last year we put a new rule in for these situations and how we go about them,’’ Foster told a pool reporter. “The initial contact was before he started to turn, while his back is to the basket, and then he flings it up.’’

Woodson said he thought the play was reviewable.

“I am up there screaming to try to get it reviewed,’’ Woodson said. “I thought it was close enough to have that play reviewed but they never entertained it.’’

Foster said his judgment on that type of foul is no longer reviewable.

“There’s nothing in the rule book — and there’s 14 triggers — that allows us to review that for continuation,’’ Foster said. “The only thing we can review is whether it’s a two or a three if we’d allowed it to be a made basket.’’

Anthony tried to miss the second free throw but it went in, giving the Rockets the ball up 1. The Knicks fouled Harden and he made both free throws with 2.9 seconds left to make it a 3-point bulge. With no timeouts left, J.R. Smith raced to halfcourt and missed at the buzzer high off the backboard.

Anthony did enough complaining on the court and said he was ready to let it go.

“My thoughts don’t mean anything at his point,’’ he said. “It doesn’t matter if I thought it was a good or not. No reason to keep harping on it. I’ve seen it multiple of times. I don’t want to see it again.’’

According to Anthony, the referees told him they didn’t review it because there were less than two minutes left in the game — contrary to Foster’s postgame comments.

The Rockets have lost two games with late 3-pointers this season and coach Kevin McHale said they have been practicing fouling on the catch at length.

“Houston informs us before the play they are going to take a foul,’’ Foster said. “The initial contact is way before what probably everybody else thinks. It’s a push, a slap and then another slap but we’ve already called the foul on the initial contact. Now he turns and throws it up. It’s not able to be scored that way.’’

Indeed when Iman Shumpert inbounded with 5.8 seconds left, Anthony bobbled the ball.

“He lost the ball up high at first and that’s when I fouled him initially,’’ Harden said. “Then he finally gathered himself and shot it.’’

For Knicks fans, it was a tough loss to swallow, especially on a night Bargnani was so solid on both ends, defending Dwight Howard, who scored just seven points, and making 9-of-12 shots. Anthony scored his season high, making 17-of-30 from the field, hitting 9-of-11 free throws and grabbing 10 rebounds.

“I thought [Bargnani] did a great job defensively, staying in front of him, taking charges, making it tough on him,’’ Anthony said.