AUSTIN (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.

(© Copyright 2017 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.)