NEW YORK -- Carmelo Anthony was sore and struggling and would've preferred to have been out of the game much earlier.
Then it came time for a game-tying shot.
"I was going to take that," he said. "Take that one regardless."
Anthony went just 7-for-28 from the field after sitting out two games with a sprained right ankle, but he made the most important shot he took, a 3-pointer from straight away over Nerlens Noel when the Knicks were on the verge of losing a game they had led by 18 points in the third quarter.
"He saved us in that moment," rookie Kristaps Porzingis said.
The Knicks finally won it in the second extra period, sparked by two baskets and a blocked shot from reserve guard Langston Galloway.
"That Philly team is a team that is definitely improving," Knicks guard Arron Afflalo said. "Just very happy to get out of here with a win."
Afflalo led the Knicks with 25 points, and Anthony had 19 points, seven rebounds and seven assists.
Porzingis had 16 points and 12 rebounds but sat out the overtimes after hurting his right foot while trying to grab an offensive rebound. Porzingis wasn't sure how he was hurt. He said his foot had a bruise, and he hoped he could return quickly.
"I'm sure I'll be fine," he said. "I expect to be back on Wednesday. I'm young. I recover quick."
Knicks coach Derek Fisher said Porzingis probably could have played in the overtimes but was held out as a precaution. Fisher said he hopes to get confirmation that Porzingis' injury is a minor one, but there is no definitive diagnosis yet.
Ish Smith had 16 points and 16 assists for the Sixers, who were seconds from a second straight victory but couldn't overcome their 13-of-25 shooting from the free throw line. Smith was just 8 for 28 from the floor and had all but two of his points after the third quarter.
"We were down 18 and found a way to not only get back in it [but] really be in a position to win the game," 76ers coach Brett Brown said. "To not see that through is really disappointing."
Noel finished with 18 points and 13 rebounds. Rookie Jahlil Okafor had 20 points in 26 minutes but didn't play after the third quarter, as Smith and Noel flourished once he went off the floor.
"I was ready. I was staying ready, but the guys had it rolling," Okafor said. "It was an exciting game."
The Knicks bounced back after losing two straight while Anthony was out of the lineup. They led 52-47 at halftime before opening an 18-point lead in the third, when the 76ers committed seven turnovers and managed just 16 points.
Anthony hoped at that point that he would be able to get some rest. He said his ankle pain hindered him all game.
"Then I looked up, and the lead just kept getting cut and cut and cut, so at that point I knew it was going to be a longer night," Anthony said.
He played 49 minutes.
Smith, just 1-for-10 through three quarters, had consecutive baskets at the end of a 9-0 run that cut it to 78-76 early in the fourth. The Sixers went ahead on Hollis Thompson's 3-pointer with 52 seconds left in regulation and were up 96-93 when Smith followed with a jumper, which set up Anthony's 3.
76ers: Jerami Grant returned after missing two games with a left calf strain. He finished with nine points in 14 minutes. Brown said before the game that Grant would be limited to 20 minutes. ... The 76ers have lost their past four meetings with the Knicks.
Knicks: The Knicks won on Martin Luther King Jr. Day for the second consecutive year and improved to 20-10 on the holiday. ... Robin Lopez had 16 points and 10 rebounds. ... F Kevin Seraphin was inactive with a bruised right rib.
A victory Monday would have been the 76ers' third in January. They won only three times all season entering the month.
76ers: Visit Orlando on Wednesday.
Knicks: Host Utah on Wednesday.
Information from The Associated Press and ESPN staff writer Ian Begley was used in this report.
After two straight losses to the Raptors in the East finals, LeBron James says panic isn't a word in his system as the Cavaliers prepare for a pivotal Game 5 in Cleveland on Wednesday night.
It could be happening to the Warriors and it's happened before. The teams with the most regular season wins in NFL, MLB and NHL history have NOT won their championships.
A young Thunder fan who dressed up as Steven Adams isn't the only lookalike around.