NEW YORK — With the score knotted at 82–82 and only 1:21 remaining on the clock, LeBron James dribbled out precious ticks in the fourth quarter. As Carmelo Anthony draped over his left shoulder, James peeked over his right shoulder with daylight hard to come by. James still collected his dribble, showed the ball on a pump fake and faded away from Anthony’s outstretched arm to knock in a critical shot.

“It was a big–time possession in the game,” James said after the Cavaliers’ 90–84 victory at Madison Square Garden on Friday. “He played some pretty good defense ... very physical. I wanted to get a shot. I trusted what I did over the summer and what I have been doing in practice and let it go.”

The field goal only counted as two points toward the Cavaliers’ effort, but it represented the culmination in yet another chapter in the rivalry between James and Anthony that has been waged since their teenage years. For those who haven’t kept count, the competition might be closer than you think. James now leads Anthony 13–12 in regular season matchups.

But James emerged late to capture another win over a familiar opponent in an arena that played host to some of his most impressive performances. James, who finished the game with 31 points and six assists, produced 12 crucial fourth-quarter points, including that fadeaway, to push the Cavaliers forward when they struggled in almost every facet of the game.

Through three quarters, Cleveland shot 40% from the field, hit 21.7% of its three-pointers and completed an abysmal 52.9% on free throws. Yet the Cavs only trailed 72–66 and remained within striking distance despite rough nights from Kevin Love and Tristan Thompson. The team offense didn’t improve much in the final period, but James and Mo Williams showed up, as they combined to score 21 of Cleveland’s 24 points in the fourth. Timofey Mozgov also contributed three points for Cleveland’s eighth straight win.

James and Williams did damage at the free–throw line. James appeared intent to live in the lane after he missed a few makeable outside shots throughout the night. There was little New York could do to deter him, with most of his drives either ending in a foul or a tough conversion. Williams, on the other hand, made a contested three-pointer and a crucial step-back jumper before closing things out at the free-throw line.

“I always preach whatever it takes for the team to win,” James said. “Obviously, offensively we struggled from the perimeter and free-throw line. I was able to make some sort of push offensively.”

Prior to James’s late bursts, however, it was Anthony who jumped out to a quick start with 22 first-half points. Anthony played his most efficient basketball yet and appeared on pace to hit the 40-point mark. But James would have none of it. He defended Anthony early and failed to thwart tough shots and contested three-pointers. Anthony couldn't get similar opportunities to go down as James’s defense tightened and made things tougher.

In turn, Anthony, whose offensive flow appeared flawless for 24 minutes, took to isolations in the post to combat James’s close defense. Anthony did get a few shots within the triangle, but he mostly tried to take on James and help defense with extra dribbles still resulting in contested looks.

“I am a two-way player,” James said. “I play both ends of the floor. I take defense as serious as offense. ’Melo is probably top three in our league as a scorer. I try to make it tough. You contest shots and you live with the results.”

•​ New Open Floor podcast: Kobe, Nets, Kings and more with Chris Mannix

In the end, James’s approach was favorable for the Cavaliers. Anthony, who had played so well, posted only 26 points on the night and converted on one of his nine attempts in the second half. Some of the blame lands on the Knicks guards for failing to find him easy shots, but there also was the feeling that Anthony’s night had simply turned. Anthony was fouled on one occasion, with the defense at his back, and still missed a point-blank layup. He converted the free throws, but the miss was emblematic of a second half that just didn’t go his way.

“Carmelo’s a tremendous offensive player and we don’t want one guy, particularly LeBron, guarding him for 48 minutes,” coach David Blatt said. “That demands an awful lot of energy. Carmelo’s a tremendous basketball player. I thought LeBron did a fabulous job on him in the second half. I really think he took the challenge. He scored 30-something, but he held Carmelo to four points in the second half. That’s not a small feat.”