Smith, who has 24 touchdown passes this season without an interception, hit Stedman Bailey with a 6-yard score with 10:50 left to play. Andrew Buie ran for 207 yards and two touchdowns, the second coming giving the Mountaineers a critical 10-point lead late.
West Virginia (5-0, 2-0) didn't seal the win until recovering an onside kick with 14 seconds left after Texas scored a touchdown on a pass from David Ash to Marquise Goodwin.
Joe Bergeron scored four touchdowns, all on short runs, for Texas (4-1, 1-1), which is 2-7 at home in conference games the since 2010.
Smith was 25-of-35 passing for 268 yards in a game he had to be sharp. Texas' aggressive defense hit him early and often and forced a second quarter fumble that the Longhorns recovered for a touchdown.
But just as he did when West Virginia ran up 70 points on Baylor a week earlier, Smith made all the big throws when the Mountaineers needed them in a game where every possession was critical. West Virginia went 5 for 5 on fourth downs.
Buie was just as important to West Virginia's ability to carve up the Texas defense. He averaged 6.7 yards against a Texas defense that continues to struggle with tackling.
The Texas defense was aggressive with its pass rush and it gave the Longhorns a chance to win.
The fumble recovery for a touchdown sparked a first-half rally that brought Texas back from a 21-7 deficit to a 28-27 halftime lead. The Longhorns forced another fumble by Smith in the fourth. But Texas couldn't capitalize when an errant snap sailed past Ash, leading to a 16-yard loss before Anthony Fera missed a 41-yard field goal attempt that would have tied the score at 41-41.
Fera, who transferred from Penn State, missed the first four games with a groin injury.