Carmelo Anthony was enjoying his best all-around performance of the season, and the only way he saw it ending was with him hitting the game-winning shot.

He had two cracks at it and delivered on the second one. Anthony’s turnaround jump shot from the left elbow with three seconds left in overtime capped his season-high 35-point outing and lifted the Knicks to a 113-111 victory over the Hornets on Friday night at Madison Square Garden.

It was their sixth straight home win and put the Knicks (8-7) above .500 for the first time this season. They have won five of their last six games overall.

“Honestly, I wanted that shot,” Anthony said. “I wanted that moment, to be honest with you. I felt like I had an opportunity to close it in regulation, and in overtime, I did want that situation.”

Anthony, who shot 14-for-25, played a complete game. He grabbed 14 rebounds, passed for five assists and made some big defensive plays, including a blocked shot in overtime, to lead the Knicks to their third consecutive win overall.

Anthony had a chance to win the game in regulation, but his jumper from the left wing rolled around the rim and spun out at the buzzer. He got a second chance in overtime with the score tied at 111, and this time he came through.

advertisement | advertise on newsday

The Knicks played a two-man game with Anthony and Derrick Rose. Anthony wanted Rose to move to the top so the Hornets couldn’t double-team him, but when Anthony turned on Michael Kidd-Gilchrist, Kemba Walker came over to help.

It didn’t matter. Anthony buried the shot. “It felt good,” he said. “Once I kind of made my move and saw the basket, the release felt good.”

Jeff Hornacek said, “We know he is going to get a good shot. You can run all the plays you want, but Melo has the experience, the size to hold guys off. He makes big shots.”

But the Knicks still needed one big stop, and they got it when Rose contested Walker. He deflected Walker’s three-point try from the right corner and the Knicks celebrated their hardest-fought win of the season. “I wanted to jam him,” Rose said. “If I would have let him get that shot off, it probably was going to go in, but I just used my height and my length against him.”

Kristaps Porzingis, who was in foul trouble for most of the night, made a huge impact in the fourth quarter and overtime. He finished with 16 points, eight rebounds and three blocks, stuffed Cody Zeller’s dunk attempt in regulation and rejected Frank Kaminsky’s in overtime.

“We got to love games like this,” said Rose, who also had 16 points. “To be this close and go overtime and then to find a way to win with a new group like this, it’s not going to do anything but give us confidence.”

Marco Bellinelli’s 19 points led the Hornets, who lost for the fourth straight game. Walker had 17 and Nicolas Batum 16 in the first game of a home-and-home that concludes Saturday night in Charlotte.

Late in the fourth quarter, Rose gave the Knicks a 104-101 lead with a jumper from the left wing. But Walker drove, made a layup, was fouled by Willy Hernangomez and converted the three-point play to tie it at 104.

advertisement | advertise on newsday

Rose scored on a spinning layup 26 seconds into the extra session to make it 106-104. It stayed that way until Anthony’s jump shot with 2:26 remaining after Porzingis’ block on the other end.

The Hornets took a 109-108 lead on Kidd-Gilchrist’s three-point play with 1:02 left. Anthony then fed Porzingis for a corner three-pointer that put the Knicks ahead 111-109.

Kidd-Gilchrist dunked to tie it with 27.1 seconds left. Out of a timeout, the ball went to Anthony, and he wasn’t giving it up. He turned on Kidd-Gilchrist and made the clutch jumper to win it.

“Melo was Melo,” Rose said. “I said the same thing about KP. We know what they’re going to do. They’re going to produce.”