Tyus Jones had 22 points, Justise Winslow added 16 points and Jahlil Okafor had 12 points and 13 rebounds for Duke.
Kennedy Meeks and Brice Johnson each scored 18 points to lead North Carolina (18-8, 8-5). Nate Britt pulled the Tar Heels within two with one free throw with 3.5 seconds left. He missed the second, Marcus Paige raced in and got his hands on the rebound - but Winslow grabbed it as the buzzer sounded.
Amile Jefferson finished with 13 points for the Blue Devils, who went up 90-89 with just under two minutes left in OT on Okafor's layup in the post.
Cook then gave Duke a two-point lead with a free throw with 31.8 seconds remaining, but missed the second to give the Tar Heels a chance.
North Carolina milked the clock and worked the ball to J.P. Tokoto, whose short jumper from the left baseline hit off the front of the rim. The rebound went to Cook, who was fouled with 5.2 seconds left.
Cook missed the first free throw but made the second to put Duke up 92-89. North Carolina got the ball near midcourt before calling a timeout. Britt was fouled before the Tar Heels could even think about hoisting a 3.
Tokoto had 15 points, Isaiah Hicks scored 12 and Britt finished with 11 points, while Johnson added 12 points before fouling out early in overtime for the Tar Heels, who have lost four of five.
Britt put them up by 10 with less than four minutes to play with his knifing layup through the lane. And then the Blue Devils stormed back.
Jones scored nine straight points for Duke, and his driving layup with 27.5 seconds left tied it at 81.
North Carolina had possession last in regulation, milking most of the clock before getting the ball to Paige. The preseason All-American took one dribble and tossed up a 3-pointer that bounced hard off the iron and into the lane.
North Carolina: Tokoto had more points in this game than in his previous three combined. He had been 3 of 15 for 14 points in his last three games.
Duke: Okafor joined North Carolina's Tyler Hansbrough in 2006 and Georgia Tech's Stephon Marbury in 1996 as the only freshmen in ACC history with 26 consecutive double-figure scoring games.
North Carolina hosts Georgia Tech on Saturday.