AUSTIN, Texas — Texas snapped its five-game home losing streak to Oklahoma State on Saturday.

Barely.

Despite controlling most of the second half, Texas needed to recover an onside kick and gain a first down in the final two minutes to hold off the Cowboys 36-30.

Longhorns quarterback Sam Ehlinger threw for 281 yards and four touchdowns, helping his team build a 36-23 lead late into the fourth quarter.

But a fumbled punt and a Chuba Hubbard touchdown run allowed OSU to get within 36-30 in the final 1:37.

Hubbard finished with 121 yards and two touchdowns. Spencer Sanders threw for 268 yards, but didn't have a touchdown and was intercepted twice.

OSU had just three points on its first three series of the second half despite reaching the Texas 9, 3 and 22.