Carmelo Anthony returned from a two-game absence with 34 points against his former team, and the New York Knicks beat the Denver Nuggets 112-106 on Sunday night to remain the NBA’s lone unbeaten team at home.

Back in the starting lineup after missing two games with a cut on the middle finger of his left hand that required stitches, Anthony twice made baskets in the final 2:08 after Denver had pulled within four points.

Jason Kidd scored 17 points for the Knicks, who bounced back from their worst offensive performance of the season a night earlier in Chicago and improved to 8-0 at Madison Square Garden. Tyson Chandler and J.R. Smith each had 15 points.

Ty Lawson had 23 points and Danilo Gallinari had 21 points and nine rebounds against the team that drafted him and later dealt him in the package for Anthony in February 2011.

Anthony decided to play after working out before the game, shooting 10 of 24 while adjusting to playing with the finger covered. He beat the Nuggets for the first time after the Knicks dropped a double-overtime game here last season.

Corey Brewer made the first two baskets of the fourth to give Denver an 88-80 lead, but the Knicks came right back with consecutive 3-pointers by Steve Novak and a dunk by Chandler to tie it. Ronnie Brewer scored the next four points to make it a 12-0 run, and after a basket by Kenneth Faried, Anthony made a jumper and a 3-pointer as the Knicks opened a 97-90 advantage.

Denver from there could get it down as close as four, Anthony nailing a jumper on one occasion and driving into the lane for another to keep the Nuggets away.

Anthony spent the first 7½ years of his career with the Nuggets, telling them in the 2010 offseason he wanted out. He and coach George Karl clashed at times during their time together, but Karl predicted their relationship would be fine someday and said he hasn’t backed away from his belief that Anthony will eventually get to the top of basketball.

“I’ve said that I feel Melo’s going to win a championship someday,” Karl said. “He’s going to figure out that scoreboard numbers and stat sheets aren’t important. It’s the team scoreboard and intangibles of the game that make winners champions.”

The Knicks gave up more than they wanted to in order to get Anthony, and the Nuggets had better balance and more success afterward. Now the Knicks seem to have found the system and personnel that fit best around Anthony, and Karl said the trade was a win-win.

“They wanted to get back to the top of the mountain and they took a chance on going out and getting one of the top 10 players in basketball. It didn’t work for a while but it looks like it’s working now,” Karl said.

Anthony was only 1 of 6 in the first quarter and the Nuggets hit 11 of 19 shots, yet Denver’s lead was only 25-23. The offenses got untracked in the second, New York outscoring Denver 38-33 to take a 61-58 lead at the break. Anthony scored 11 points in the period, when the Knicks made 16 of 17 free throws.

NOTES: Knicks F Rasheed Wallace missed the game with a sore left foot. … Corey Brewer finished with 15 points after scoring 19 or more in three straight games, tying a career best.