North Carolina survived a game for the ages from Providence guard Bryce Cotton, and when the Tar Heels needed it most they made shots from the free throw line in the final seconds of a 79-77 victory on Friday night in the NCAA tournament.

UNC has been one of the worst free throw shooting teams in the nation this season, but junior forward James Michael McAdoo made one of his two attempts with 3.5 seconds to play. McAdoo missed the second, but he rebounded his own miss and then was fouled again, and again went 1-for-2.

The miss went out of bounds off Providence, and the Tar Heels celebrated a narrow victory that keeps their season alive. UNC, the No. 6 seed, advanced to the round of 32, where on Sunday they’ll play against either Iowa State, the No. 3 seed in the East region, or N.C. Central.

The final seconds capped a wild final few minutes at the AT&T Center, where Providence seemed to be in control after erasing a nine-point deficit. The Tar Heels twice led by nine in the second half – the second of those times with a little more than 11 minutes to play.

Behind Cotton, though, Providence stormed back. The Friars led by as many as seven points, with 4 1/2 minutes to play, but UNC didn’t fold. After Providence went ahead 71-64, UNC went on a 7-0 run and tied the game on a Marcus Paige 3-pointer with three minutes remaining.

Providence went ahead by three again, and UNC tied it again – this time on a three-point play from J.P. Tokoto, who made a spinning layup in the lane and was fouled in the process with 2 minutes, 20 seconds remaining.