STILLWATER, Okla. (AP) — Taylor Cornelius had received his share of local criticism after Oklahoma State lost two straight contests, with some people calling for him to be pulled from the starting lineup.

But Cornelius rebounded in a big way Saturday night, throwing three touchdown passes and running for two scores, the last with 5:44 remaining, to help Oklahoma State beat No. 6 Texas 38-35.

“Corn Dog’s a tough guy, he’s a competitor,” said Oklahoma State coach Mike Gundy of Cornelius. “He’s got a good demeanor, he’s tough, he’s unselfish, the team loves him. He was good tonight. He needed to come back and do well.”

Cornelius completed 23 of 34 passes for 321 yards, and his scoring run on third-and-10 gave Oklahoma State (5-3, 2-3 Big 12) a 38-28 lead after its 31-14 halftime advantage had been whittled down to just three points.

“It was just a zone read, I pulled it and did my best to get in,” Cornelius said of that touchdown.

Tylan Wallace had 10 receptions for 222 yards and two touchdowns. It was the Cowboys’ fourth straight over Texas and seventh in their last nine meetings.

“He is a special player,” offensive coordinator Mike Yurcich said of Wallace. “He’s got a knack for timing his jump up so he plays a lot taller than what he is, especially on vertical throws. The bigger the game, it seems the bigger he is going to play. He is just the guy that is very dependable.”

For Texas (6-2, 4-1), Sam Ehlinger returned from a shoulder injury suffered in the previous game. After struggling a bit in the first half, Ehlinger completed 17 of 27 passes for 175 yards and two touchdowns in the second half. He also rushed for 47 yards and two touchdowns on 10 carries.

“We just started playing our football,” said Ehlinger of the turnaround in the second half. “We’ve learned throughout the course of the season that when we play our best, no one can stop us, and we have to capture that and play like that 100 percent of the time, not just at the end of the game.”

Tre Watson’s 1-yard touchdown run with 1:46 remaining pulled Texas to 38-35, but Dillon Stoner recovered the ensuing onsides kick for Oklahoma State. The Cowboys were then able to run out the clock after Cornelius gained a first down on third-and-4 with an 8-yard rush.

“Extremely proud of the way that our guys fought in the second half,” Herman said. “When we pulled to within three with 11 minutes left, I don’t think there was any doubt in anyone’s mind on that sideline that we were going to win the game. But we didn’t, and we didn’t play our best down the stretch.”

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