The Terriers (8-4) led the entire second half and by as many as 14 points before holding off UNC's late-game run for a huge road win and their first win over a ranked team in 23 games.
The Tar Heels (10-2) got within a point twice and missed four 3-pointers for the tie in the final 6 minutes. But they never could overtake the Terriers, who played confidently and kept counter-punching every time UNC made a run.
The Terriers closed it out with four straight free throws in the final 15.2 seconds to seal it, then mobbed each other at midcourt as the horn sounded and the Tar Heels headed to the locker room.
Joel Berry II scored 23 points to lead UNC, which suffered its first loss to an unranked team while ranked in the top five since falling to Boston College in January 2009.
Wofford: The Terriers were picked to finish sixth in the Southern Conference. But Magee and the Terriers closed the first half on an 8-0 run to take a 34-33 lead, then made 10 of 15 shots out of the break to steal momentum and put UNC in catch-up mode. More importantly, they never folded even as the Tar Heels kept inching closer and closer.
UNC: This wasn't the way the Tar Heels wanted to follow a tough weekend road win at No. 21 Tennessee. They were often sloppy with the ball, spent much of the game missing shots and struggling to get consistent defensive stops. Luke Maye struggled offensively (17 points on 4-for-16 shooting) and UNC finished the game shooting just 36 percent.
Wofford: The Terriers visit UNC Greensboro on Dec. 30 in Southern Conference play.
UNC: The Tar Heels face Ohio State on Saturday in New Orleans for the CBS Sports Classic.