MORGANTOWN, W.Va. (AP) Sam Ehlinger helped Texas get that elusive win over a ranked opponent.

Ehlinger threw two touchdown passes and the Longhorns became bowl eligible under first-year coach Tom Herman with a 28-14 win over No. 24 West Virginia on Saturday in a game in which the Mountaineers lost quarterback Will Grier to injury.

Texas (6-5, 5-3 Big 12) qualified for a bowl for the first time since 2014, which was former coach Charlie Strong’s first season. The Longhorns also beat a ranked opponent for the first time in five tries this season.

”We know we’ve got one left, but this was a big one,” Herman said. ”This was a big hurdle – to get another road conference win, to beat a top 25 team, and make sure that our seniors are bowl eligible. These guys are ecstatic.”

Texas didn’t give up a sack and the running game had its best effort in more than two months. The Longhorns entered with 13 touchdown passes, and Ehlinger got two in the second quarter.

”Coach kept saying just keep swinging and keep swinging, it’s going to pay off,” Ehlinger said. ”I think we did an excellent job of that as a team – just keep moving forward.”

Ehlinger’s 50-yard pass to Reggie Hemphill set up Ehlinger’s 4-yard TD toss to Kendall Moore. Ehlinger did most of the work on the Longhorns’ next drive. He went from sideline to sideline for a 17-yard gain on third down, ran 23 yards after catching a pass from wide receiver Jerrod Heard, then found Chris Warren for a 23-yard score just before halftime for a 14-0 lead.

”He’s tough. He’s a competitor,” Herman said of Ehlinger. ”He gives us a dimension in the run game – 7.6 yards per carry. That’s a pretty good day at the office. We knew it would be difficult throwing the football against this defense.”

Grier left the game in the first quarter with an injured throwing hand when he landed awkwardly as he dove for the end-zone pylon on a run. The middle finger of his right hand was bent backward and he did not return.

West Virginia coach Dana Holgorsen said Grier had a broken finger.

”Injuries are a part of college football,” Holgorsen said. ”When that happens, guys need to step up. We’ve talked a lot about that. Guys need to step up and go in there and they need to play.”

Backup Chris Chugunov couldn’t get much going. He threw a 12-yard scoring pass to Ka’Raun White early in the fourth quarter to pull West Virginia within 21-14. But the Mountaineers (7-4, 5-3) didn’t score again.