Gallinari scored 23 points, hitting a crucial 3-pointer in the waning seconds, and the Nuggets came back to beat the Cleveland Cavaliers 98-91 Friday night for their fourth consecutive victory.

“We were down the whole game, but we fought hard in the fourth quarter and made the right plays in the last couple of minutes to get the win,” said Nuggets guard Ty Lawson, who drove the lane for a tiebreaking layup before dishing off to Gallinari for the clinching 3-pointer with 34.9 seconds remaining.

Kosta Koufos added a career-high 21 points, and Kenneth Faried had 17 points and 11 rebounds to help the Nuggets overcome 22 turnovers, which matched a season high and led to 24 Cleveland points. They beat the Cavaliers for the 10th time in the last 13 meetings in Denver.

Kyrie Irving, playing despite an illness, scored 28 points to lead the Cavaliers. Dion Waiters had 18 points and Tristan Thompson 16.

“We’re still young and dumb and don’t understand what we have to do in the third quarter,” Cleveland coach Byron Scott said after the Cavaliers, up 11 at halftime, were outscored 53-35 in the second half.

“It happens over and over,” he said. “I’m tired of us giving games away and that’s what we did (Friday night). They came out aggressive, and we were on our heels the rest of the half. If we would have matched their aggressiveness, the way they came out, it could have been a different story.”

A dunk by Thompson put the Cavaliers up 62-50, but the Nuggets got a 3-pointer and a three-point play from Gallinari during an 11-0 run, pulling to 62-61 with 5:43 left in the third quarter.

Cleveland, which got a 3-pointer from Luke Walton and a putback dunk from Tyler Zeller, fought back to take a 76-72 lead into the fourth.

After Irving’s 3-pointer from beyond the top of the key gave Cleveland an 85-80 lead, the Nuggets put together a 7-0 burst, going in front 87-85 on a short hook by Koufos, who scored on an array of shots from in close.

“The guards did a heck of a job finding me in the key,” Koufos said.

Said Scott: “We lost track of him. He worked his way underneath the defense a few times. They are a very good interior passing basketball team.”

Lawson’s driving layup with 1:48 left snapped an 89-all tie and after Cleveland couldn’t convert on its next two possessions, Gallinari connected on his decisive 3-pointer.

“I’m always confident. I’m always ready to take those shots,” Gallinari said. “I was wide open. Ty got the ball to me, and it felt good leaving my hand. I thought it was going in as soon as I released it. It was an important shot, and it was important that we got this win at home.”

C.J. Miles, who missed Wednesday’s win over Atlanta because of a back strain, hit a 3 for the final points of the second quarter to stretch the Cavaliers’ halftime lead to 56-45. It was their biggest advantage at that point.

Kosta Koufos of the Nuggets scored a career-high 21 points in Denver’s win over Cleveland on Friday night.

Barry Gutierrez/Associated Press

Kosta Koufos of the Nuggets scored a career-high 21 points in Denver’s win over Cleveland on Friday night.

Nuggets notes

Luke Walton scored eight points in his return to the Cavaliers after missing the previous two games to tend to personal matters. ... Kenneth Faried has 29 career double-doubles, including 17 this season.