LAS VEGAS — Kristaps Porzingis made his biggest gaffe as a Knick, then made up for it sweetly in overtime.

In his summer showdown against Jahlil Okafor, Porzingis’ seventh foul proved to be the saltiest. Just as the Knicks summer team was about to go to 3-0, an overaggressive Porzingis made contact with Sixers guard Scottie Wilbekin while blocking his 3-point attempt with 1.9 seconds left and Philadelphia down three.

For the first time, the normally poised 19-year-old Porzingis looked perplexed, arguing the call. Wilbekin drained all three free throws to knot the score and force a two-minute overtime.

Nevertheless, the Knicks prevailed to stay unbeaten, with Porzingis blocking a layup attempt by Okafor, the No. 3 overall pick, in the final minute to preserve the 83-81 win at Thomas & Mack Center, after which a small group of Knicks fans chanted Porzingis’ name.

“He’s really good,’’ Okafor said. “He’s a top-five pick for a reason. He’s a helluva player. Looks like he could do everything and he has the respect of his teammates.’’

The Okafor-Porzingis matchup had some Vegas buzz. After all, the Sixers had the choice of taking either the more ready low-post monster Okafor at No. 3 or the bigger gamble but bigger upside in the 7-foot-3 European.

Porzingis finished with nine points, three blocks, three rebounds and three assists in 22 minutes, while Okafor finished with 18 points and six rebounds. Porzingis took just five shots, making three. He continued to show more grit than glitz — something no one envisioned.

“I surprised people who had never seen me play before,’’ Porzingis said. “They thought the skinny guy from overseas can’t play. I haven’t had a great game yet. I’m playing OK, playing hard. Fans appreciate that and cheer for me.”

Porzingis is averaging 10.0 points and three rebounds through three games, and has yet to make a 3-point basket, but, as one scout said, “he’s doing the things people didn’t think he’d do.’’

“He loves to compete,’’ Knicks coach Derek Fisher said. “A lot of young guys don’t love the game and competing and mixing it up the way he does. I don’t think he thinks of his frame as a disadvantage. He’s willing to get down and dirty. I think he showed that tonight. He stood up to Okafor and played him. Statistically, Okafor won the game but Kristaps’ team won. That’s the major stat that tells you the difference between guys.’’

In the early going, Porzingis sank a long 2-point shot over Okafor, who responded by backing him in like a rag doll and drawing a foul. Porzingis picked up seven fouls, but said he’s taking more chances in summer league because of the 10-foul limit. He promised to adjust in the regular season and he adjusted in the second half on Okafor, fronting him. But his eagerness cost him with the last-second foul on the Wilbekin 3-point try.

“I guess at that moment it wasn’t a foul, but later on the replay, I could’ve stayed on the ground and lifted my hands up on the shot. I guess it was a foul,” Porzingis said.

And it was a clean block in the final minute on Okafor.

“I’m trying to play hard defense, every stop is very important for us,’’ Porzingis said. “I got another block and helped my team win. I’m a shotblocker.’’

The Sixers went with the safer choice in Okafor. Ironically, Knicks general manager Steve Mills revealed on MSG Network that Clarence Gaines, Phil Jackson’s top adviser, graded Porzingis as the No. 1 pick in the draft over Okafor and Karl-Anthony Towns.

According to a source, Philly ownership may have played a role in wanting a more finished, well-known product to fill seats at Wachovia Center. But Porzingis looks like he’ll be drawings fans at the Garden.

Undrafted out of Ohio University, power forward Maurice Ndour is making inroads in getting a training camp invite, scoring 23 points (10-15) with six rebounds and a key late block on Okafor. … Point guard Jerian Grant had 12 points, four assists and five rebounds in running the new souped-up triangle.