The Knicks had a relatively comfortable lead Thursday night when things became a little uncomfortable inside the Garden.

Kristaps Porzingis banged knees with Magic center Nikola Vucevic early in the fourth quarter. He fell moments later and then stood up, holding his right knee. Porzingis walked gingerly off the floor and headed right to the locker room, limping badly, as the fans held their breath.

But Porzingis returned from the locker room and rode an exercise bike while laughing, talking to and fist-bumping fans as the Knicks wrapped up a 106-95 victory over the Magic.

Porzingis suffered a right knee contusion and was relieved that it was nothing more serious after feeling “a sharp pain.” He was available to return, but the Knicks (16-13) had a double-figure lead and there was no need to bring him back. “He was ready to come back in,” Jeff Hornacek said. “But with the game like it was, if we could keep him out, even better.”

The Knicks are off until they play the Celtics on Christmas Day, so Porzingis will have some time to rest. “We’ll see how it feels [today],’’ he said. “It hurts a little bit. But I wanted to come back in the game. They didn’t want to — I guess they wanted to be cautious and not put me back in. But it’s not that bad.”

Derrick Rose’s 19 points led six Knicks in double figures. Carmelo Anthony and reserve center Willy Hernangomez had 15 each. Backup big man Kyle O’Quinn added 14 points and 16 rebounds and Brandon Jennings came off the bench for 12 assists in 22 minutes. Porzingis had 12 points and Courtney Lee had 10.

advertisement | advertise on newsday

The Knicks got a huge lift from the bench as the reserves totaled 44 points. “Our bench was fantastic,” Hornacek said.

The Knicks were up nine when Porzingis left the game. With five subs on the floor, the lead grew to 98-80 on Justin Holiday’s three-pointer.

Hernangomez scored 12 points in the fourth quarter, including eight straight. He made it 102-85 by throwing down a dunk after a behind-the-back pass from Jennings.

Serge Ibaka had 23 points and 10 rebounds for Orlando (13-18). Evan Fournier scored 21.

Orlando is one of the best rebounding teams in the NBA, but the Knicks built a 52-41 edge on the boards.

“They’re very talented,” Magic coach Frank Vogel, who interviewed for the Knicks’ vacancy during the offseason, said before the game. “I like the moves that Phil [Jackson] has made to fill out the roster around Carmelo. Kristaps has really, really developed from year one to year two and is just a special talent and playing at a big-time level. I like the point guard play that they’re getting. They’ve got a solid addition in Courtney Lee. [Joakim] Noah’s a warrior. This team has a chance to be really good this year.”

Said Rose, “We’re building something, even though we don’t know what we have yet. We know that everybody has the same goal, and that’s what we’re pushing for.”

The Knicks built a 16-point lead in the first half with Jennings setting up his teammates for easy scores. He had eight assists in 11 minutes; the Magic had nine total.

The Knicks took a 44-28 lead when Jennings fed Porzingis for a layup. The Magic cut its deficit to 59-54, but the Knicks answered with a 14-2 run and went ahead 73-56 on Porzingis’ transition layup on a pass from Lee.

“You can’t brag about anything,” Rose said. “[This] was a good win. We were supposed to take them out in the first half. They found a way to come back like every NBA team is good, they have good players, but we have to find a way to keep them down.”