NEW YORK (AP) — North Carolina was up 16 with 5 1/2 minutes left, all set to cruise to a victory that would snap a six-game Atlantic Coast Conference Tournament losing streak against Duke and put the Tar Heels in the championship for a record 35th time.
Then things got weird — and college basketball's greatest rivalry produced another memorable finish.
Luke Maye scored 17 points, including North Carolina's last field goal with 5:33 remaining, and the 12th-ranked Tar Heels held off a rally by No. 5 Duke for a 74-69 victory Friday night in the ACC semifinals.
"I have nothing to say about the last five minutes," North Carolina coach Roy Williams said, able to joke because ultimately it turned out OK for the Tar Heels. "(Assistant) Coach (Steve) Robinson coached that part of the game. You guys be sure and tell Coach Rob I said that. It was unbelievable."
The sixth-seeded Tar Heels (25-9) will face top-seeded and top-ranked Virginia on Saturday night at Barclays Center in Brooklyn in a rematch of the 2016 ACC championship, won by North Carolina.
Maye hit a jumper to give North Carolina what seemed like a safe 72-56 lead. But the Tar Heels went cold and got sloppy and second-seeded Duke went on a 13-0 run, drawing within three on Gray Trent Jr.'s 3 with 50 seconds left.
The Tar Heels turned the ball over on consecutive possessions to give Duke (26-7) opportunities to tie.
"I think toward the end, we were just trying not to make mistakes and we ended up making mistakes instead of just continuing to be aggressive," North Carolina senior Joel Berry II said.
Duke couldn't convert. Grayson Allen was called for an offensive foul, drawn by Kenny Williams, driving to the basket, and then Allen missed a 3, trying to draw contact on Maye.
Theo Pinson, who dropped the ball out of bounds with 11 seconds left, made two free throws with 3.2 seconds left to seal it.
"I made a big-time turnover that I needed to make up for, and I'm going to be honest, I was like, you're making these two free throws," Pinson said. "Like you just almost blew the game for your team, so you have to make them."
The Tar Heels beat their heated Tobacco Road rivals for the first time in the conference tournament since the 1998 championship game. They also evened the series in Brooklyn at 1-1. Duke beat the Tar Heels in the semifinals at Barclays last season.
Pinson had seven of North Carolina's 24 assists on 28 field goals as the Tar Heels cut up Duke's zone most of the night.
Marvin Bagley III followed up his 33-point, 17-rebound game against Notre Dame on Thursday with 19 points and 13 rebounds for Duke. Fellow freshman Trent added 20 points and Wendell Carter Jr., another frosh, had 14 points and nine rebounds.
Allen received a Flagrant 1 foul for hip-checking North Carolina's Garrison Brooks as the Tar Heels forward was running up court late in the first half.
Brooks went down hard and stayed down in the backcourt as North Carolina scored. Officials stopped play and went to the courtside monitor to check a replay. Allen clearly stuck his backside out enough to bump the unsuspecting Brooks while the 6-foot-9 freshman was in the middle of a stride. Brooks was OK and made two free throws with 52.7 second left.
"They got a fast break and I bumped him and fouled him," Allen said during the postgame news conference.
Brooks told reporters he felt Allen intentionally bumped him, and when Allen was asked about it coach Mike Krzyzewski jumped in.
"Any foul in the game is not . you don't want any foul," Coach K said. "So that was another foul in a game. Do you think that was the only time someone was hipped in the game? If you look in the low post, it's going on all the time. So it happened at half court. They got it. It's done. And that didn't win or lose the game."
Allen, a senior, was reprimanded by the ACC for tripping two opponents in his sophomore season. He was stripped of his captaincy by Duke for another trip as a junior.
North Carolina: A night after Duke earned its 100th ACC Tournament victory, the Tar Heels did the same. Both are 100-45 in the conference tournament. North Carolina is looking for its 19th tournament championship. That would leave them one behind Duke for the most.
Duke: The Blue Devils had six turnovers on their first 14 possessions and just one field goal in the first 10 minutes of the game. With four freshmen starters, the Blue Devils might have the most talented team in the country.
"But we have to accept some slippage," Krzyzewski said. "For tonight, look, I'm disappointed we didn't win, but we've got to move on, learn from it."
North Carolina: The Tar Heels scored 49 points in a road loss to Virginia on Jan. 6.
"We've got to go in there and try to play the perfect game," Williams said. North Carolina will also try to become the second ACC team to win four games in four games to win the tournament. Duke did it last year.
Duke: The Blue Devils will find out Sunday if they did enough to earn a top seed in the NCAA Tournament. Last year after North Carolina lost to Duke in the ACC semifinals, the Blue Devils won the ACC but the Tar Heels won the national championship.
"I think we're much better prepared for the NCAA Tournament than we were a month ago, and these two games will help us, even though we lost tonight and could have played better," Coach K said.
Follow Ralph D. Russo on Twitter @ralphDrussoAP