NEW YORK (AP)RJ Barrett’s end-to-end driving dunk with 0.6 seconds left in regulation had the basket shaking.

The Toronto Raptors remained perfectly steady.

”It didn’t matter. We’ve just got to keep fighting,” forward Scottie Barnes said. ”When he made the dunk, we were going to overtime. We were focused on winning the game.”

That’s what the Raptors did.

Fred VanVleet scored 33 points, Barnes had 26 and the Raptors recovered to beat the New York Knicks 123-121 on Monday.

Pascal Siakam had 20 points, nine assists and eight rebounds for the Raptors, but he was on the bench after fouling out when Toronto had to wait out Jalen Brunson’s missed 3-pointer in the final second before emerging with the victory.

”We’ve come out on the wrong side a few times so you’ve just got to learn from it,” VanVleet said after Toronto’s fourth win in five games. ”I thought today we just kept pushing, we made some big plays, and I thought we just played well as a team.”

O.G. Anunoby hit two 3-pointers in overtime as Toronto built a six-point lead, but New York nearly erased that in the final minute.

Barrett, who is from Toronto, scored 32 points and Brunson had 26 for the Knicks, who had a three-game winning streak snapped. Julius Randle finished with 21 points, 15 rebounds and eight assists, after scoring 42 points in a win Sunday at Detroit.

The Knicks led 101-92 with 5 1/2 minutes to play in regulation before Toronto surged back with a 12-3 run, capped by five straight points from VanVleet to tie it at 104 with 1:30 remaining.

VanVleet then nearly had a costly mistake, fouling Brunson purposely in the backcourt with 18 seconds left as if the Raptors were behind, when in fact it was tied. He called it a boneheaded play, but it didn’t cost Toronto and he was able to joke about it afterward.

Barnes hit two free throws for a 109-108 lead with 12 seconds left, but when he hit only one with 6.6 seconds to go, Barrett went all the way up the middle of the floor and no Raptors stepped in to stop him before his dunk made it 110-all.

”I thought it was a hell of a play, and that’s how the game went – back and forth,” Knicks coach Tom Thibodeau said. ”It was a quick turnaround for us, and we kept fighting the whole game.”

Quite a highlight, but not what Barrett most wanted.

”The win would have been the most special thing,” he said.

Anunoby hit a couple 3s early in the extra period before Siakam, who scored a career-high 52 points in Toronto’s victory here last month, converted a three-point play that made it 121-115 with 1:23 remaining.

Toronto’s victory last month sent the Knicks on a five-game losing streak, but they’ve otherwise been playing some of the league’s best basketball since the beginning of December. They had won eight in a row right before that skid and are 7-2 since it ended.

Gary Trent Jr. scored 18 points for Toronto and Anunoby finished with 10.

TIP-INS

Raptors: VanVleet scored just three points on 1-for-9 shooting in a loss to Atlanta on Saturday and was listed as questionable for this game with low back soreness, an injury that caused him to miss two games at the end of December. … The game began a stretch where the Raptors play 10 of their 12 games on the road. One of the home games is a rematch with the Knicks on Sunday.

Knicks: Brunson was chosen Eastern Conference player of the week after averaging 34.8 points while the Knicks went 3-1. … Immanuel Quickley scored 14 points.

UP NEXT

Raptors: At Milwaukee on Tuesday.

Knicks: Host Washington on Wednesday.

AP NBA: https://apnews.com/hub/NBA and https://twitter.com/AP-Sports