De’Andre Hunter finished with a team-high 15 points before fouling out late in overtime. (Rob Kinnan/USA Today Sports)

The third-ranked Virginia men’s basketball team blew a double-digit lead in the second half, matched its season high for turnovers and had two starters foul out in the final minutes Tuesday night at No. 23 N.C. State.

Despite the litany of foibles, the Cavaliers survived, but just barely.

Their 66-65 win in overtime at PNC Arena was complete only when, with a chance to tie the score, N.C. State’s Markell Johnson missed the first of three free throws and made the next two with nine-tenths of a second to play.

Virginia’s Ty Jerome inbounded the ball to fellow guard Kyle Guy, who flung the ball high into the air, allowing the final buzzer to sound on the Cavaliers’ seventh consecutive win against N.C. State.

Virginia (19-1, 7-1 ACC), which committed 16 turnovers, moved into a first-place tie in the conference with Duke.

Guy had put the Cavaliers ahead to stay with his only three-pointer of the game with two minutes left in overtime. Virginia’s scoring leader finished with 10 points but shot 3 for 11, including 1 for 5 from beyond the arc.

“We made enough good plays and hung in there and got some lifts from guys,” Virginia Coach Tony Bennett said. “I thought we had some chances to separate a little bit, but they made some big plays. Thankful for the win, but need to grow from this and learn from it.

“We brought losing into the equation when I didn’t know we had to in certain situations with fouls.”

In just such an instance, Johnson had been awarded the potential tying free throws when he got Virginia forward De’Andre Hunter off his feet while shooting a three-pointer and drew contact. That was Hunter’s fifth foul, and the sophomore exited with a team-high 15 points on 4-for-8 shooting with five rebounds and four assists.

Starting center Jack Salt, meanwhile, had fouled out with 30 seconds left in the second half, also sending Johnson to the foul line.

Johnson made both to tie the score, and Jerome’s short jumper bounced off the rim at the buzzer, sending Virginia to its first overtime game this season.

Jay Huff replaced Salt in the post and got the Cavaliers started in overtime with a three-point play on a two-handed dunk and bonus free throw. The 7-foot-1 redshirt sophomore center chipped in eight points, making all three of his field goal attempts.

Johnson led the Wolfpack (16-5, 4-4) with 14 points and six rebounds.

A 14-point lead wasn’t enough to allow Virginia to win in regulation. The Cavaliers had reached that margin on a three-pointer from Jerome with 12:17 to play, but North Carolina State began to chip away, trimming the deficit to 45-41 with 8:03 to go during a surge in which Johnson and Devon Daniels made three-pointers.

N.C. State played its second straight game with Johnson back in the lineup. The junior point guard had missed three games after hurting his back in a fall against Pittsburgh on Jan. 12. The Wolfpack went on to lose two of three without him.

Bennett, during this week’s ACC men’s basketball coaches conference call, described Johnson as a stabilizing force for North Carolina State. Johnson has been particularly effective during the second half of games this season, scoring 63 percent of his points after halftime heading into Tuesday.

The Cavaliers, meanwhile, have now won three straight games since their lone loss against Duke on Jan. 19, but only after barely hanging on in this one.

“It was a feeling of relief,” Guy said. “It was a bad game on our part. Coach was actually mad after the game and got after us because we didn’t play anywhere near our standards. He holds us to a high standard, so we know we didn’t play very well.”

The Cavaliers entered Tuesday with an overall average margin of victory of 24 points in the conference behind the stingiest scoring defense in Division I (52.6). They also were ranked first nationally in turnovers per game (8.4) and three-point field goal percentage defense (24.9).

Defense kept Virginia in front during a disjointed first half in which it committed eight turnovers and attempted just one three-pointer. Still the Cavaliers led 27-23 going into the locker room when Braxton Key collected a pass from Jerome and sank a short jumper at the buzzer.

“N.C. State plays good defense,” Bennett said. “They’re good with their hands. They’re athletic and aggressive, and they did rattle us and take us out of our rhythm. Some of our offensive fouls and decision-making, our defensive fouls at inopportune times, almost cost us the game.”