AUSTIN — Kansas State and Texas went toe-to-toe for more than four hours Saturday night, trading highlight plays and clutch touchdowns for the entirety of regulation and two overtimes until only one of them was left standing.

It was a pivotal game for both teams, arguably their biggest of the young season, so it was fitting that it all came down to a single play.

Texas emerged with the 40-34 victory thanks to a hard-earned touchdown run from Chris Warren in which he scored in the middle of a rugby-style scrum and dragged a dozen players across the goal line.

The Longhorns (3-2, 2-0 Big 12) earned the right to celebrate by continuing their recent string of encouraging games with another win. The Wildcats (3-2, 1-1) were left searching for answers after letting another road game slip away that was up for grabs.

“I’m just frustrated,” K-State defensive back D.J. Reed said. “Great game. I mean, those are the games we love. It was a close game, double overtime. We worked so hard, we wanted things to go our way, and they didn’t. We are really in shock right now.”

The biggest culprit in this loss was K-State’s defense. The Wildcats entered the game allowing 308.5 yards per game, a number that ranked 21st nationally and first in the Big 12, but surrendered one big play after another against the Longhorns. Behind freshman quarterback Sam Ehlinger, Texas piled up 546 yards on 91 plays and won despite two missed field goals and a turnover on downs at the end of a 77-yard drive.

It was unclear whether Ehlinger or Shane Buechele would lead Texas in this game, and K-State coach Bill Snyder said he prepared his team for both possibilities. But it was clear the Wildcats weren’t ready for the quarterback they saw.

Ehlinger completed 30 of 50 passes for 380 yards and two touchdowns, adding 107 rushing yards on designed runs and scrambles.

“There wasn’t much difference in the game plan for each quarterback, but they definitely caught us by surprise,” K-State defensive back Kendall Adams said. “As far as speed they are pretty much the same, but (Ehlinger) ran with some power and he was breaking tackles, keeping plays alive. That really kept their offense going.”

In particular, Ehlinger found success on draw plays. Seemingly every time K-State brought pressure, he spotted the blitz and found a running lane.

“I think it was major in the ballgame,” Snyder said. “That’s the thing I’ve been concerned about all week ... His ability to bring the ball out ... They got some big plays out of it.”

The biggest came in overtime, which began with the score tied at 27-27. Texas put pressure on K-State immediately when Ehlinger found Jerrod Heard wide open across the middle for a 25-yard touchdown on the first play.

The Wildcats stayed poised and responded with a touchdown drive of their own, capped by an eight-yard run from backup quarterback Alex Delton.

K-State got the ball first in the second overtime, but moved back to the edge of field-goal range on two holding penalties. Matthew McCrane, who made his first two field goals of the night, missed off the left upright from 53 yards.

Then Texas won the game on its final possession.

“We’re getting there,” Texas coach Tom Herman said. “We have tasted what it feels like to win and win close ballgames. We’ve also tasted what it’s like to lose close ballgames. So, I think we’re well aware of the difference in that taste and the steps necessary to make sure that we’re on the right end of that.”

Still, both teams showed serious resolve in a game that rarely went according to script. Against logic, an offensive shootout broke out between K-State and Texas. The way both teams had been playing this season, it seemed like this was going to be a defensive grind, the type of game that felt like a fistfight in a ditch.

It didn’t play out that way. This game was filled with offense from the moment McCrane connected on a 54-yard field goal to give the Wildcats a 3-0 lead.

When Jesse Ertz hit Dalton Schoen across the middle for a catch-and-run touchdown pass of 82 yards early in the second quarter, K-State fans probably thought a 10-0 lead felt like a major cushion.

But momentum went bouncing back and forth like a ping pong ball from there.

Texas answered with a touchdown drive of 71 yards, capped by a one-yard run by Kyle Porter. K-State fired back with another touchdown pass to Schoen, this one for 12 yards. Schoen, a walk-on sophomore, is rapidly becoming one of the Wildcats’ best offensive weapons.

Then the Longhorns ripped off touchdown drives of 78 and 50 yards to close out the half and take a 21-17 lead, but the Wildcats fought back.

K-State gained momentum under the most unlikely of scenarios, with Delton taking over for Ertz late in the third quarter and leading the Wildcats on a pair of late scoring drives.

Ertz exited the game following an apparent knee injury. It’s been a while since we have seen the K-State senior run at full speed. He appeared to play through minor injuries a week ago against Baylor, and his health was the subject of much speculation leading up to this game.

He was fit enough to play the majority of the way in this game, completing 12 of 18 passes for 224 yards and two touchdowns, but he still didn’t look right running the ball. Eventually, he felt too banged up to continue and asked out. Delton came in immediately gave the Wildcats a spark.

Noticeably faster than Ertz, he reeled off a series of impressive runs and found the end zone on a keeper from two yards away with 3 minutes, 37 seconds in the third quarter. He later put K-State in position for a field goal, and led the team in overtime. Delton completed 2 of 5 passes for 30 yards and added 79 rushing yards

He put the Wildcats in position to win, but the Longhorns finished.

“It wasn’t about effort, it wasn’t about caring and it wasn’t about all those kind of things,” Snyder said. “It boiled down, really, to execution. We didn’t execute the things that we needed to do, and we’ve got to do a better job.”