Quinshad Davis had two touchdown catches for the Tar Heels (3-5, 2-3 Atlantic Coast Conference), who won in Carter-Finley Stadium for the first time since 2005. Davis' second score came off a 59-yard pass from Ryan Switzer on a trick play, putting UNC ahead for good midway through the second.
Logan's score gave the Tar Heels a cushion that ultimately held up, with A.J. Blue running for a key first down with about 2½ minutes left to help UNC drain the clock on the Wolfpack (3-5, 0-5).
Brandon Mitchell ran for 105 yards and a touchdown to become the first Wolfpack quarterback to crack the 100-yard mark in 37 years, but the Wolfpack couldn't give coach Dave Doeren a winner in his rivalry debut.
Mitchell threw a costly interception after Logan's score, prompting Doeren to turn to backup Pete Thomas for what amounted to the Wolfpack's last best drive. Thomas got the Wolfpack to midfield before his fourth-down pass for Rashard Smith fell incomplete with 2:42 left.
Blue's 10-yard run on third down moved the chains, and the Wolfpack didn't get the ball again until there were just 13 seconds left. Mitchell's final heave was caught well short of the end zone for the final play, sending several UNC players running to the Wolfpack's midfield logo to celebrate before players from both teams had to be separated there.
N.C. State had won five straight meetings, its longest run since 1988-92, before last year's wild game in Chapel Hill. The Tar Heels won that one 43-35 on Gio Bernard's oft-replayed 74-yard punt return for the go-ahead score with 13 seconds left, giving UNC coach Larry Fedora a successful debut in the long-running rivalry.
N.C. State jumped out to a 10-0 lead and had plenty of momentum, but the Tar Heels rallied - with a boost from a botched fake punt by N.C. State from its own 30 - with a pair of first-quarter touchdowns that took some of the energy out of the Wolfpack's home crowd.
Niklas Sade also kicked four field goals, but two came on drives that stalled inside the 10 and proved costly as time ran out. The Wolfpack led 16-14 before the Switzer-to-Davis TD throw with 9:43 left in the second quarter.
Marquise Williams threw a touchdown pass for UNC, while Bryn Renner ran for a score and played through an injury to his left shoulder late in the game.