Donovan Smith threw a 49-yard touchdown pass that was caught by Stephon Johnson as time expired to give Houston a thrilling 41-39 win over West Virginia on Thursday night.

Smith finished 21-of-27 for 253 yards and four touchdowns. He threw a Hail Mary from midfield, the ball was tipped at the goal line and Johnson caught it to end the game.

“We practiced that, and we always have a guy who is ready for the tip,” Smith said. “We just executed that.”

Smith, who completed his final 16 passes, also ran for a touchdown as Houston (3-3, 1-2 Big 12) earned its first Big 12 win.

“Donovan Smith came alive at the end of the second quarter and had a great drive for a touchdown and then a great second half,” Houston coach Dana Holgorsen said. “The kid is turning into a really good player.”

Holgorsen described the play as “incredible” and Smith’s throw as “unbelievable.”

“We played all four quarters,” Holgorsen said. “I don’t know how that happened at the end. I guess the football gods were on our side today. We’ll take it. It’s good to get that first Big 12 win. … I’m just proud of that group in there for hanging in there. Donovan Smith and Boogie Johnson, I’ve never been a part of that.”

Johnson caught four passes for 96 yards and two scores, and Stacy Sneed rushed for 78 yards on seven carries.

“It wasn’t really planned to be tipped to me,” Johnson said of the final play. “It just happened like that, and I made a play on that. I’m just thankful we were able to pull out the win.”

Garrett Greene threw for 391 yards and two touchdowns. Greene, who was 20-of-38 passing, also rushed for 47 yards and two touchdowns for West Virginia (4-2, 2-1). The loss snapped West Virginia’s four-game win streak.