BLACKSBURG, Va. (AP) -- North Carolina's defense is as good as advertised. T.J. Yates, Shaun Draughn and the offense are improving, too.
Casey Barth kicked a 21-yard field goal on the final play and the Tar Heels ' defense, ranked seventh in the nation, stopped No. 14 Virginia Tech all night long in a 20-17 victory on Thursday night.
One week after blowing an 18-point lead in a 30-27 home loss against Florida State that had them reeling, the Tar Heels put their troubles in the past and handed the Hokies their second loss in a row. Twelve days earlier, Tech was in the national championship hunt.
''I've never really had this feeling before,'' Yates said after making several key completions. ''Kicking it at the last second? It just sends chills down your spine.''
The Tar Heels (5-4, 1-3 Atlantic Coast Conference) got their first conference win after forcing a fumble by Ryan Williams at his own 24 with 2:02 left and running out the clock.
Barth's field goal, his second in the final 3 minutes, just made it official.
''We knew we had to get back to the drawing board,'' Draughn said after running for 77 yards. ''To come back and play the way we did definitely speaks volumes about out team.''
The reverse may be true of the Hokies (5-3, 3-2), who until losing to No. 11 Georgia Tech 12 days ago were in the thick of the national championship picture and feeling good.
Now, with their slim ACC championship game chances probably also squandered?
''I think the motivation is to come out here so you don't feel like this again,'' linebacker Cody Grimm said, dismissing a 10-win season as a motivator. ''Ten wins is one thing, but I don't want to feel like this any more and the only way to do that is to win.''
No one felt worse than Williams, who started the night averaging 119 rushing yards, gained 96 and was hoping to lead the team down the field to a win until he lost the ball.
''As of right now, there probably isn't really anything they can say to lift me up because regardless of what anybody says, personally I feel like I kind of took the game away from us today,'' Williams said. ''It was on the line, it was in my hands and I fumbled.''
The loss was the Hokies' first in six ACC games against the Tar Heels .
Tydreke Powell caused Williams to fumble for just the second time this season - the first was on a muffed punt in the opener - and Deunta Williams recovered, setting the Tar Heels up at the Hokies 24. After six carries by Ryan Houston , Barth's chip shot won it.
Yates, who was knocked out of the Tar Heels 20-17 loss to the Hokies last season, finished 18-for-28 for just 131 yards. He was sacked twice, both in the first quarter.
He hit Jheranie Boyd from 13 yards in the first half for the game's first points, and Greg Little from 15 yards as the Tar Heels answered immediately after the Hokies tied it.
Yates did make one big mistake, throwing a dump pass that Rashad Carmichael intercepted at the North Carolina 11, setting up the second of Tyrod Taylor 's two touchdown runs. That gave the Hokies a 17-14 lead with 11:51 left, but Yates engineered a 16-play, 78-yard drive to a tying field goal and then the defense, fittingly, made a big play to get the win.
''I thought it was his best performance,'' Tar Heels coach Butch Davis said of Yates.
The Hokies finished with just 256 yards and 11 first downs.
They finally came to life with their first possession of the third quarter, and a huge play by Taylor early in the drive saved it. Facing a third-and-17 from his 11, Taylor dodged pressure and rifled a 22-yard pass to Dyrell Roberts for the first down.
Taylor followed with passes of 16 yards to Danny Coale and 15 to Xavier Boyce , Williams ran for 22 to the Tar Heels ' 14 and Virginia Tech needed seven plays to punch it in.
Taylor did that on fourth-and-goal from the 1 to tie it at 7.
The Hokies other scoring drives covered 35 yards to a field goal and 5 yards to a TD.
Taylor was 11 for 23 for 161 yards, was sacked three times and rushed numerous other times, causing him to throw the ball away. He ran the ball nine times for minus 8 yards.
The Tar Heels had done virtually nothing on offense until midway through the second quarter. On a drive that covered 84 yards in 13 plays, Yates hit Greg Little for 17 yards, Little ran for 23 around the right side to the Hokies 16 on a third-and-3 and Yates hit Boyd for 13 yards in the right corner to make it 7-0 just 2:44 before halftime.
The Hokies gained 45 yards on the first two plays of the game and seemed primed for another big Thursday night. But Jarrett Boykin fumbled after a 20-yard reception on the second play and Kendrick Burney recovered for North Carolina at its 27. The Hokies also drove to the Tar Heels 38, 34, 37 and 35, 40 before halftime and had nothing to show for it.