The Tar Heels let an eight-point halftime lead melt away in the second period and the game was still in doubt when the Wildcats closed within three with just under a minute to play.
Hairston then drove to the basket and made a layup with 42 seconds to play. He was fouled by James Bell and the 3-point play gave the Tar Heels enough breathing room to produce the victory.
North Carolina will take on Kansas in the third round on Sunday after the Jayhawks narrowly avoided becoming the first No. 1 seed to lose a game since the tournament expanded to 64 teams 28 years ago. The matchup with Kansas will send North Carolina Coach Roy Williams against his former school.
With the Tar Heels' win, three of the four teams from the Atlantic Coast Conference advanced into the tournament's third round.
Hairston scored 23 points and James Michael McAdoo added 17 for North Carolina (25-10). The Tar Heels were outrebounded and gave up more turnovers than did Villanova, but they hit 11-of-21 from 3-point range.
JayVaughn Pinkston paced Villanova (20-15) with 20 points.