MORGANTOWN, W.Va. (AP)Backup quarterback Garrett Greene ran for two touchdowns and threw for a third score, and Casey Legg’s 25-yard field goal as time ran out lifted West Virginia to a 23-20 victory over Oklahoma on Saturday.

West Virginia (4-6, 2-5 Big 12) beat the Sooners for the first time since joining the Big 12 in 2012. The Mountaineers avoided being eliminated from bowl consideration but still must win its final two games to qualify for the postseason.

Oklahoma (5-5, 2-5) will have to wait another week to try to become bowl eligible.

The Sooners had the chance to retake the lead but Zach Schmit’s 46-yard field goal try hit the right upright with 6:24 remaining.

West Virginia took over at its 29 and Greene drove the Mountaineers the length of the field. He converted a fourth-down pass for 5 yards to Bryce Ford-Wheaton to the Oklahoma 34 and he ran 7 yards on third down to the Oklahoma 10 with 51 seconds left.

That set the stage for Legg, who has made all 13 of his field goal tries this season.

Oklahoma’s Marvin Mims rushed for 211 yards, including TD runs of 12 and 5 yards. His second score put the Sooners ahead 20-13 late in the third quarter. Mims now has 1,113 yards for the season.

Greene played two series in the first half and the entire second half in relief of JT Daniels. Greene’s 11-yard TD run that followed his 16-yard pass to Kaden Prather on fourth down early in the fourth quarter tied the score at 20-20.

Greene finished with 119 rushing yards on 14 carries. He completed 12 of 22 passes for 138 yards.

Daniels had his second straight lackluster outing. He completed 7 of 12 passes for 65 yards and threw his seventh interception in the last five games. He also was sacked to push the Mountaineers out of field goal range late in the second quarter.

EXTRA-POINT FOLLIES

After Greene’s 5-yard TD run just before halftime, West Virginia’s Kolten McGhee dropped the extra-point snap in the rain. Kicker Casey Legg grabbed the ball and briefly looked toward the end zone before he was hit by Oklahoma’s Robert Spears-Jennings and fumbled. McGhee made another attempt to pick up the ball, but Oklahoma’s Billy Bowman scooped it up and ran 88 yards for two points, giving the Sooners a 12-6 halftime lead.

THE TAKEAWAY

Oklahoma: The Sooners piled up 236 rushing yards but were held scoreless in the fourth quarter. The Sooners now have the most losses in a season since 2014 and have been eliminated from the Big 12 title chase. This marks the first time since 1998-99 that Oklahoma will not have back-to-back seasons of at least 10 wins.

West Virginia: Sitting the immobile Daniels for the second half against a swarming Oklahoma defense was the difference.

UP NEXT

Oklahoma hosts Oklahoma State next Saturday. The Sooners have won the teams’ last three meetings in Norman, Okla., and eight of the past nine at home.

West Virginia hosts No. 23 Kansas State next Saturday. The Mountaineers have won the last three games against the Wildcats in Morgantown.

More AP college football: https://apnews.com/hub/college-football and https://twitter.com/ap-top25. Sign up for the AP’s college football newsletter: https://tinyurl.com/mrxhe6f2