TORONTO -- Point guard Kyle Lowry put the Toronto Raptors ahead to stay with a driving hook shot with 28.9 seconds to play.
But it was forward Rudy Gay who put the Raptors in a position to hand the New York Knicks their fourth consecutive loss.
Gay scored 26 of his 32 points in the second half and made some important free throws in the final minute of the Raptors' 100-98 victory before a crowd of 19,800 at Air Canada Centre on Friday.
"(Lowry) made two big plays, but down the stretch I thought that Rudy put us on his back and carried us," Raptors head coach Dwane Casey said.
"Rudy's a good player that's why they brought him over from Memphis," Knicks head coach Mike Woodson said. "He's been playing great basketball for this team. He's one of those go-to guys that can make plays down the stretch. He made some big shots for them."
The Raptors (23-33) beat the Knicks (32-20) for the second time in nine days as DeMar DeRozan added 18 points and Lowry scored 15. Amir Johnson chipped in with 12 and John Lucas 10 after coming off the bench.
Carmelo Anthony led New York with 32 and J.R. Smith scored 19 with Amar'e Stoudemire adding 14 and Raymond Felton 10.
"They made the plays down the stretch and we didn't," Woodson said.
Both teams had a chance to break a 95-95 tie, but it was Lowry who hit a six-foot hook shot to give the Raptors a two-point lead with 28 seconds to play.
"He made a tough shot," said Knicks center Tyson Chandler.
"We got the switch and they were switching all night," Lowry said. "I wanted to try to get to the basket instead of taking the jump shot. That's a great defender (Chandler), he was a defensive player of the year so I just tried to get my right hand and get the floater off and to get the shot over him."
Chandler had a chance to tie the game but he hit only one of two free throws with 21.4 seconds before he fouled out to send Gay to the line. Gay hit both free throws to put the Raptors up, 99-96.
Anthony missed a shot and with 8.9 seconds left and Gay made one of two free throws putting Toronto ahead by four points. Anthony added two points in the final seconds.
"We fought back but offensively we didn't play so smart down the stretch," Chandler said. "We've just got to get out of the slump, right now we're in a slump. We played hard enough to win but just made some mistakes in execution.
"They came up with the big plays. We played really hard on the defensive end but offensively we didn't take advantage of them in the penalty. We had a couple of 3-on-2, 4-on-1 breaks that we didn't capitalize on."
The Raptors led by nine points going into the fourth quarter. But Steve Novak's 3-pointer and Stoudemire's dunk got the Knicks to within two with 9:04 to play. Lucas answered with a 3-pointer.
Shortly after Lucas' bucket, a fan ran onto the court, was caught and carried off by security.
The Knicks came back to tie on Smith's 3-pointer and then he made a layup to put New York up by two with 6:09 to play.
But Johnson tied it again at 88-88 with a layup.
Gay made a pair of free throws to put Toronto up 91-89 with 3:53 to play. After the Knicks were stopped on their next possession, the Raptors went up by four on Gay's jumper.
Trailing by three at the half, the Raptors took a 56-53 lead with DeRozan scoring six of Toronto's first eight points in the third quarter. The Raptors built the lead up to nine after Gay, who had 17 points in the third quarter, scored on a layup and a jump shot. The lead reached 13 when Gay hit a 3-pointer with 3:02 to play in the third.
"I just wanted to be aggressive," Gay said. "Up until (the third quarter) I was letting the game come to me. Then shots started falling. I started going to the basket and I got some foul shots (and was 9-for-11 from the line)"
The Knicks cut into the lead with Chandler sinking a couple of free throws to cut Toronto's lead to 79-70 at the end of the third period.
The Knicks led 51-48 at the half on 50 percent shooting from the field with Anthony leading the way with 17 points on 7-for-14 shooting.
The Raptors were shooting 41.5 percent but were 5-for-10 in 3-point attempts. Neither team led by more than six points in the first half and there were 12 lead changes and the score was tied seven times.
Anthony scored 13 points and Lowry had 12 on 4-for-4 shooting from 3-point range, and the teams were tied at 32-32 after the first quarter.
Notes: Backup point guard Sebastian Telfair who was obtained from the Phoenix Suns on Thursday was not in the Raptors lineup for Friday's game against the Knicks. He'll be the third point guard behind Lowry and Lucas. "He's an insurance policy," Casey said. "Nothing is going to change for our team." ... The Knicks were coming off a 125-91 loss at the Indiana Pacers on Wednesday in which they gave up 74 points in the first half -- 44 in the second quarter -- and trailed by as many as 39 points. "We didn't show up," Woodson said. It was the Knicks' first game since the All-Star break. They went into the break losing 92-88 to the Raptors at New York. ... The Knicks are home to the Philadelphia 76ers on Sunday while the Raptors host the Washington Wizards on Monday.