AUSTIN, Texas (AP) Texas Tech's season was slipping away and with it perhaps coach Kliff Kingsbury's job.

The Red Raiders were trailing 23-13 in the fourth quarter when senior quarterback Nic Shimonek, benched for the last game of the regular season, walked over to his coach.

''I told him he was about to run out of time,'' Shimonek said. ''And then he put me in.''

Given his chance, Shimonek delivered for his team and for Kingsbury with two fourth quarter touchdown passes leading the Red Raiders to a 27-23 win over Texas Friday night. Kingsbury's future had been in doubt after five seasons, but the rally made the Red Raiders (6-6, 3-6 Big 12) bowl eligible after missing the postseason last year.

After the game, Texas Tech athletic director Kirby Hocutt said Kingsbury will return for a sixth season in 2018.

''Kliff has led this program the right way. We're not where we want to be, but we're not far off,'' Hocutt said.

Kingsbury admitted he questioned his own future before the game.

''At times it slips into (your mind) because you think about missing your players. That's the hardest part. You try to focus on what you can control and that's get your team ready,'' Kingsbury said. ''I want to be here.''

Shimonek, the starter all season, had been benched for McLane Carter, but came in with the Red Raiders trailing 23-13. His first drive included a 51-yard completion and his short touchdown pass to T.J. Vasher cut it to 23-20.

The game winner, a 16-yard pass to Cameron Batson, came with 2:07 to play. The touchdown was set up by a 52-yard interception return to the Texas 14 by Justus Parker.

''Everybody in the entire locker room loves (Kingsbury),'' Shimonek said. ''He's an unbelievable coach. We'd all go to war for him.''

Texas' final drive ended when Longhorns quarterback Sam Ehlinger threw another interception at the Texas Tech 20 with 1 minute to play.

Ehlinger passed for 239 yards and a touchdown but the Texas offense slogged through most of the final three quarters. The Longhorns ran for just 18 yards and had deep drives end in field goals of 19 and 20 yards by Josh Rowland instead of touchdowns.

Texas (6-6, 5-4) had already clinched its first bowl berth since 2014 under first-year coach Tom Herman but must win its postseason game to avoid a fourth consecutive losing season.

THE TAKEWAY

Texas Tech: Hocutt, who is also the chairman of the selection committee for the College Football Playoff, quickly answered the question about the future of his program with his commitment to Kingsbury for 2018. Kingsbury is 30-32 with three losing seasons in five years at the program where he once was a record-setting quarterback. Kingsbury's decision to start Carter was risky but he made the right move in the fourth quarter to go back to Shimonek.

''He told me we were gonna try something new. I had my opinions and thoughts about it,'' Shimonek said. ''I would have been happy so long as we won ... Hats off to him for trusting me.''

Texas: The loss will make for a bitter off period before the bowl game. The Longhorns missed the chance to earn a seventh win for the first time since 2013 and the chance to end the regular season on a three-game win streak. The offense continues to be the problem for the Longhorns, who have struggled to move the ball all season under coordinator Tim Beck.

''We are dead set in making it our mission in life in making sure these seniors go out with a positive experience and a win in a bowl game, wherever that may be, and give us some momentum in the offseason,'' Herman said.

SHORT FIELD FAILURES

Texas lost in large part because it couldn't punch the ball into the end zone for touchdowns. The drives that ended in short field goals both had first-and-goal inside the Red Raiders' 5 yard line. The running game continued to get pushed around at the line of scrimmage.

''We're playing hard and really physical,'' Herman said. ''We just don't play really well and really smart at times,''

BIG TURNOVERS

Texas Tech lead the Big 12 in forced turnovers and got four in the second half with two fumble recoveries and the two big interceptions. The Red Raiders didn't capitalize on the fumbles in the third quarter but they at least kept the Longhorns off the field. The interceptions were game changers.

''We put our defense in some really bad situations,'' Herman said. ''We just ran out of gas, ran out of momentum.''

UP NEXT:

Texas Tech: Bowl game to be announced

Texas: Bowl game to be announced

Copyright 2017 by AP. Any commercial use or distribution without the express written consent of AP is strictly prohibited.