It was going to be a sweet end to a four-game losing streak. Rookie point guard Immanuel Quickley was weaving an electric performance. RJ Barrett was playing like a bull. Julius Randle again looked like an All-Star.
But it all came tumbling down Friday in Cleveland, delivering the Knicks their fifth straight loss in a heartbreaking 106-103 loss to the Cavaliers at Rocket Mortgage Arena.
The late-game goat was Barrett, who committed two turnovers in the final 1:19, but credit Cavaliers center Andre Drummond, a Westchester County native, and ex-Knick Damyean Dotson for extending the Knicks’ woes, as they fell to 5-8.
Drummond, who will be a free agent this summer, had a fine audition in pounding the Knicks for 33 points and 23 rebounds. Dotson landed the knockout blows with seven points in the final 2:40.
The D & D show ruined a terrific performance by Quickley, who scored 23 points off the bench, making 3 of 7 3-pointers.
“It’s a tough one especially because we really played hard,’’ said Barrett, who broke out of a slump with 20 points on 7-for-12 shooting. “It’s over now. We have to learn from those little mistakes, move on and try to get a win. I think we’re trying. We’re putting in the work, fighting as much as we can. I think we’ll be all right.’’
Barrett’s turnovers were the killers.
First, Barrett sank a desperation 20-footer before the shot clock buzzed to bring the Knicks within 98-97 with 1:33 left. But then he lost control while dribbling between his legs, turning the ball over with 1:19 left.
“I tried to go behind my back and Drummond kicked the ball,’’ Barrett said. “I’ll know for next time I [have] got to make a better play. It’s on me.”
Barrett’s miscue prompted a clear-path foul on Dotson, who sank two free throws. The Cavaliers kept possession, and Dotson drove for a layup. With 2:40 left, Dotson hit a big 3-pointer over Quickley to give the Cavs a five-point lead.
With the Knicks down four, Barrett got stripped again with 20 seconds left to ice it for Cleveland.
“In terms of the turnovers, they were costly,’’ coach Tom Thibodeau said. “It’s late, it’s the fourth quarter of a game, and we have to understand that part of a game is a lot different. The intensity is different, the way it’s officiated is different, so I think a big part of learning is trial and error. So hopefully we can learn from it.’’
Barrett, who made 2 of 4 3-pointers after entering the game in a horrid slump from beyond the arc, realizes he ultimately will be judged by his late-game performances if he’s going to be an All-Star.
“In the NBA, the fourth quarter is so intense. The energy, everything picks up, and every possession is really important,’’ Barrett said. “I’ve learned that in the NBA.’’
Drummond devoured hobbled Mitchell Robinson, who hurt his ankle. The Cavaliers big man scored 20 points and hauled in 14 rebounds in the first half. Seven of his rebounds were on the offensive glass.
The Mount Vernon native may be on the move following this season, and the Knicks will have a load of cap space. The Cavaliers may be willing to let the former Connecticut star go now that they have snared ex-Nets center Jarrett Allen in the four-team James Harden trade.
Drummond was superb — even going 13-for-19 from the free-throw line. Thibodeau attempted to foul him with the Knicks down three with 30 seconds left in the hope he’d miss both shots.
“He’s a career  percent free throw shooter, so at that point you’re just trying to create something that you think will give you an advantage, so it didn’t work out,’’ Thibodeau said.
It didn’t work out, though the Knicks made it dramatic with a 16-0 second-half run that wiped out a 12-point deficit. Quickley helped lead another charge, as did Randle, who poured in 28 points with six assists.
Backup center Nerlens Noel notched six blocks, but Robinson didn’t seem right and was a minus-19. Drummond had his way against a player in Robinson who may or may not receive a contract extension.
Quickley was spectacular coming off the bench, exploding for 12 points in 11 minutes with two assists in the first half. Quickley shot 5-for-8 from the field, making two 3-pointers in the first half.
Quickley, who was selected with the 25th pick of the first round in November, found creases in the Cavaliers defense and got the Knicks into a five-point lead playing mostly with the “Quickley Quintet’’ that killed the Cavaliers in preseason. The only difference in the young five-man band was Reggie Bullock in Barrett’s place.
In one lovely moment, rookie Obi Toppin, in his second game back from a three-week absence due to a calf strain, stole a pass and fed Quickley for a 3-pointer.
On the next possession, Quickley weaved inside and lofted an alley-oop lob for a Mitchell Robinson stuff and a 43-39 lead.
Robinson couldn’t compete with Drummond’s muscle, then he got hurt. Robinson fell awkwardly after missing a putback dunk. Coach Tom Thibodeau let him hobble up and down the court for two possessions before yanking the young center, and he went to the locker room. Robinson had his ankle taped at halftime and came out for the third quarter, looking less than 100 percent.