The first meeting between the two leading Rookie of the Year candidates went to Kristaps Porzingis. Karl-Anthony Towns displayed a better all-around game, but Porzingis had the better all-around team.

Carmelo Anthony flirted with a triple-double, and the Knicks built a 22-point third-quarter lead before holding off Minnesota, 107-102, Wednesday night at the Garden for their second straight win.

Towns, the No. 1 overall pick, was strong on the perimeter and inside, and finished with 25 points, 10 rebounds and one block in his Garden debut. Porzingis struggled with his shot but made an impact inside with his size and length.

Porzingis shot 4-for-14, including 1-for-6 from three. He had 11 points, seven rebounds and equaled a career high with seven blocks. Two of them were Towns’ shots.

“He’s talented and proved it again in this game,” Towns said. “He’s a versatile player and I can’t wait to be playing him for the next 20 years plus.’’

advertisement | advertise on newsday

Porzingis said that “would be amazing” and called it “a dream” for both players. But he said he didn’t view this as a measuring stick for him.

“I’m not really focusing on that,” Porzingis said. “Just trying to be better than him.”

Anthony was the one who did it all for the Knicks.

He was a facilitator right from the beginning, and registered 20 points, 15 rebounds and nine assists. Arron Afflalo had a big night. He shot 9-for-14 and scored a game-high 29 points, and made seven foul shots in the final 1:25 to help the Knicks (12-14) ice the game.

Kristaps Porzingis of the Knicks defends against fellow rookie Karl-Anthony Towns of the Timberwolves at Madison Square Garden on Wednesday, Dec. 16, in New York City. Photo Credit: Jim McIsaac

The Knicks went on a 29-6 run in the second quarter and led by 20 at the half. The T-Wolves (9-16) got within 99-94 with 48.7 seconds left after a Zach LaVine jumper. On the next trip, Afflalo was fouled going to the basket and made both for a 101-94 Knicks lead with 28.7 seconds to go.

Knicks videos

Andrew Wiggins scored 23 for the T-Wolves, who have dropped eight of nine and four straight. Ricky Rubio nearly had a quadruple-double — nine points, 12 assists, 10 rebounds and eight steals.

It may have been the first NBA game between the 7-3 Porzingis and the 6-11 Towns, but it wasn’t the first time they met. There was draft night and rookie orientation, and one thing stood out to Towns. “I’ve never had to look up at somebody,” he said. “I was fairly surprised to not be the tallest person in the room.”

They weren’t matched up against each other much, but when they were, Towns had to look up at Porzingis and shoot over him.

Porzingis, who rebounded well from his first scoreless game as a pro Saturday night in Portland, seemed to have fresh legs. He blocked six shots in the first half. He rejected Towns inside in the first quarter and on a three-point try on the Wolves’ final possession. But Towns scored over Porzingis a few times late in the game, including a basket inside that he converted into a three-point play with 11.4 seconds left that made it 103-100. But Afflalo made two free throws with 10.9 seconds to go to give the Knicks a five-point lead.

“Towns is good, man,” Anthony said. “Towns is very good, especially down there in that post. I didn’t realize he was shooting the ball that well. I thought KP on the other hand did a great job on the defensive end, rebounding, getting a little gritty and dirty down there. Those two guys will be in this league for a long time to come.”