The Hurricanes had taken their first lead of the game on Lamar Miller's 30-yard touchdown run with under 3 minutes remaining, but Thomas quickly responded with the game-winning score as the clock wound down.
Thomas finished with 23-of-25 passing for 310 yards and three touchdowns while rushing for two scores for the Hokies (5-1, 1-1 ACC).
David Wilson contributed 128 yards on 23 carries and Jarrett Boykin added seven receptions for 120 yards and a touchdown for Virginia Tech.
Miller ended with 166 rushing yards on 18 carries for the Hurricanes (2-3, 0-2).
Theater accidentally screens 'Nymphomaniac' trailer instead of Disney's 'Frozen'
Britney Spears on kissing Ryan Gosling, Justin Timberlake in the Mickey Mouse Club