Knicks forward Carmelo Anthony tugs on the jersey of Los...

Knicks forward Carmelo Anthony tugs on the jersey of Los Angeles Lakers' Kobe Bryant, who had 14 points in his final game against the Knicks on Sunday, March 13, 2016. Credit: AP / Alex Gallardo

LOS ANGELES — Kobe Bryant’s final game against the Knicks was filled with late-game drama, with Bryant and Carmelo Anthony exchanging big baskets.

But it wasn’t Bryant who came through with the clutch basket. Nor was it Anthony. He didn’t even get the ball on the last play.

It was Jose Calderon who delivered the winning three- pointer with two-tenths of a second left as the Knicks beat the Lakers, 90-87, on Sunday night at Staples Center.

Anthony wanted the ball on the last play, but Bryant overplayed him and wouldn’t let him get it. So Calderon took the ball from Robin Lopez and hit a three-pointer that silenced the crowd and left Bryant standing there with a big smile on his face.

“It was a very emotional situation from the standpoint of competing against one of the greats, a friend, a brother for the last time,” Anthony said. “The way the game played itself out, we didn’t want it to come down to the wire. But it was one of the games for the ages.”

The Knicks (28-40) squandered a 16-point third-quarter lead and had to play catch-up in the final minutes. Anthony had 26 points, Lopez 16 and Calderon nine. Kristaps Porzingis didn’t play because of a stomach illness. Lou Williams led the Lakers (14-53) with 15 points. Bryant had 14 and shot 5-for-15.

Bryant gave the Lakers an 81-76 lead with a turnaround fadeaway with 3:16 left. He connected again from the baseline to put Los Angeles on top 85-81 with 1:32 left. But Anthony buried a three-pointer and a long jumper to give the Knicks an 86-85 lead with 54.8 seconds left.

After Williams knocked down a jumper, Lopez was fouled with 29 seconds left and made one of two to tie it at 87-87. Bryant had the chance to give the Lakers the lead, but his baseline jumper rimmed out and Anthony rebounded it with 9.3 seconds left.

Out of the timeout, Calderon inbounded to Lopez and nearly threw the ball away. He gathered it and looked to throw it to Anthony, who couldn’t get open. So Calderon, who missed a potential winning three in San Antonio earlier this season, stepped up.

“There weren’t too many options out there,” he said. “I felt open for a minute — shoot it.

“I’m really happy for it. We got the win. It was perfect.”

After the final horn, Knicks players paid their respects to Bryant. He spoke to Calderon for a long time. Calderon said the conversation was in Spanish and they talked “about everything.”

Bryant scored his first NBA point against the Knicks in 1996 and had a then-MSG-record 61 points in 2009. That mark stood until Bryant’s good friend, Anthony, scored 62 five years later.

But big games from Bryant don’t happen that frequently anymore. Injuries and Father Time have caught up to him.

“He’s an assassin,” Anthony said. “You can’t take no plays off going against him even now. You see flashes of him out there. He still has that look in his eyes when he gets the ball. You still have to pay close attention to him. We’re definitely going to miss that.’’

Knicks interim coach Kurt Rambis said Bryant is one of a kind. “He’s a competitor and a winner,” said Rambis, who was an assistant coach on two of Bryant’s five championship teams. “We all, to some degree, throw around the word ‘great’ when we’re describing players, but he is truly one of the greatest players to ever play the game. He’s one of those rare, rare players that comes along once in a lifetime.”

Phil Jackson knew this day would come. The Knicks’ president is happy to be a spectator, watching from a distance with fond memories of how it was instead of how it is.

Jackson said he didn’t want to be Bryant’s coach when the Lakers star was on his last legs. To Jackson, Bryant will always be one of the fiercest competitors and greatest winners. But Bryant isn’t the same player or same competitor as he nears the end of his playing career.

“One of the things I told him was I never want to have to coach you at this stage of going out because it can be such a difficult time, not being able to play at the level you want to and not having a team that is competitive,” Jackson said. “But he’s done it gracefully and I think he’s been appreciated by the fans.”

Jackson and Bryant captured five championships together. Jackson remembers coming to work at 8:30 in the morning and finding Bryant sleeping in his car. He already had worked out on his own before the team practiced. Bryant was committed to being great and trying to make sure his team won.

“I would be going into film study and he’d be coming out of his first workout that started at 6 in the morning and he would take a nap between that and the team workout,” Jackson said. “I had to respect the dedication that he played basketball with and the desire that he had. Those moments brought us together when I’d see him over there and then we’d meet and have breakfast before anybody else came in.”

Bryant appears to be enjoying this farewell tour. He’s being cheered and celebrated in every city, and smiling much more than he ever has on the basketball court. He used to wear a scowl and fed off the fans treating him like a villain.

“Kobe’s always one that thrived on a vitriolic fan relationship where he’s the guy that comes into town that everybody boos,” Jackson said. “But he’s turned that around this year, and it’s nice to see.”

Before the game, Anthony anticipated it being difficult for him, knowing he was facing Bryant for the final time in an NBA game. Bryant was someone Anthony looked up to, someone who befriended him. Bryant doesn’t let many people into his inner circle, but Anthony was one of the few, which had him torn up about Sunday night.

“For me, it’s going to be emotional,” Anthony said. “You guys won’t see it. But on the inside, it will be an emotional day just knowing this is the last time I’ll be able to compete against a guy like that.”

They became friends while playing against each other in the Western Conference for the first 7½ seasons of Anthony’s career. Bryant’s Lakers, coached by Jackson, beat Anthony’s Nuggets in the 2009 Western Conference finals.

Their friendship grew in All-Star Games and from playing together on the U.S. Olympic team.

“It wasn’t forced,” Anthony said. “It happened organically, naturally, just by competing against one another, a mutual respect that I had for him and that he gained for me and then we got a chance to really connect on that USA Team.”

Bryant was a sounding board for Anthony during the 2011 All-Star Weekend, just before Anthony was traded to the Knicks, and at other times when he faced criticism and scrutiny in New York. When Anthony was a free agent two summers ago, Bryant tried to recruit him to the Lakers before Anthony re-upped with the Knicks.

“Everybody on this level needs somebody we can talk to, somebody that we can relate to, somebody that tells you straight up, tells you how it is whether you’re right or whether you’re wrong,” Anthony said. “We all need that, we all need those people. He was one of those guys.”

Porzingis out with illness. Kristaps Porzingis came to Staples Center on the bus with the team but left the building long before tipoff, returning to the team hotel because of a stomach illness that kept him out of the game. Derrick Williams started in his place.

Arron Afflalo returned to the lineup after missing the previous two games with a strained right abdominal muscle. Rambis brought him off the bench rather than start him, as Sasha Vujacic started his third straight game.

Lance Thomas was out for the fourth straight game because of left knee soreness that he aggravated while shooting before the first game of this trip last Monday in Denver.