NEW YORK -- Carmelo Anthony was sore and struggling, and would have preferred to be 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."
He made it with 3.4 seconds left in regulation, and the New York Knicks beat the Philadelphia 76ers 119-113 in two overtimes Monday.
Anthony was 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 after the Knicks were on the verge of losing a game they led by 18 points in the third quarter.
"He saved us in that moment," rookie Kristaps Porzingis said.
They 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 trying to grab an offensive rebound.
Ish Smith had 16 points and 16 assists for the Sixers, who were seconds away 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 but 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 he would be able to get some rest, saying 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.
Really long - 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, setting 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 he would be limited to 20 minutes. ... The 76ers have lost the last four meetings.
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.
Porzingis wasn't sure how he was hurt, saying 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."
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.