Zion Williamson took on 7-foot-6 Tacko Fall at the end and won, and top-seeded Duke survived when two last-ditch shots by UCF rolled off the rim.
Aubrey Dawkins finished with 32 points, but his tip-in try just missed Sunday, and Duke advanced with a 77-76 victory to reach the Sweet 16.
Williamson had 32 points, including a layup over Fall with 14.4 seconds left and his team trailing 76-73. Williamson was fouled and missed the free throw, but RJ Barrett scored on a putback to put Blue Devils (31-5) ahead.
Ninth-seeded UCF (24-9) had a final chance, but B.J. Taylor missed a short jumper and Dawkins failed on his tip attempt with less than 2 seconds left. Duke got the rebound, ran out the clock and moved on to the Sweet 16 for 27th time and fourth time in the past five years.
Dawkins cringed at the miss. His father, Johnny, is the UCF coach and was a former Duke star and longtime assistant under coach Mike Krzyzewski.
Barrett finished with 16 points.
Virginia Tech 67, Liberty 58
The Hokies advanced to the Sweet Sixteen for the first time in 52 years by beating the 12th-seeded Flames in San Jose.
Kerry Blackshear had 19 points and nine rebounds for fourth-seeded Virginia Tech (25-8). The Hokies' only other trip this far in the tournament was in 1967, when they lost to the Dayton in the regional final.
Ahmed Hill added 14 points and Justin Robinson scored 13 to help the Hokies beat an in-state rival and advance to a matchup with top-seeded Duke.
Darius McGhee scored 15 points to lead Liberty (29-7), which won its first tournament game ever Friday against Mississippi State. Caleb Homesley was held to eight points on 3-for-11 shooting after scoring 30 points to fuel the first-round upset.