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.''

TAKEAWAY

Texas: After a lot of speculation all week about whether Ehlinger would play coming off a shoulder injury to his throwing arm in Texas' last game, a 23-17 win over Baylor on Oct. 13, the sophomore quarterback did start, but struggled early. He completed just 2 of his first 8 passes for 29 yards through the first quarter-plus of the game, missing open receivers several times, and was just 5 of 15 for 108 yards in the first half, as Texas dug itself a 31-14 hole by halftime. Ehlinger was much better in the second half, sparking the Longhorn comeback attempt.

Oklahoma State: The Cowboys once again got off to a strong start (they led at some point early in each of their three losses this season) and demonstrated some uncharacteristic aggressiveness on offense. Two of Cornelius' touchdown passes, of 17 and 36 yards, came on 4th-and-1 situations, and another time on 4th-and-1, a fake punt threat resulted in a Texas offside penalty and a first down. While the Cowboys again had trouble offensively in the second half, scoring fewer than 10 points after the break for the fourth time this year, they were able to pull it out in the end. Two missed field goals by Matt Ammendola (from makeable distances of 41 and 38 yards) also hurt.

POLL IMPLICATIONS

The loss will likely drop Texas out of the top 10, but they shouldn't fall much farther than that, considering it was such a close game and they very nearly pulled off the big comeback.

TURNING POINT

Oklahoma State went 3-and-out on the possession after Texas pulled to within 31-28 early in the fourth quarter, but Zach Sinor boomed a punt 57 yards to the Texas 9-yard-line, where Brandon Jones caught it and then ran backwards before the Cowboys pinned him down at the 2. On third-and-9, it looked like Ehlinger completed a 19-yard pass to Lil'Jordan Humphrey, but a holding penalty on guard Patrick Vahe nullified that play and Texas ended up punting. A 10-yard return by Dillon Stoner gave Oklahoma State the ball on the Texas 35-yard-line, and six plays later, Cornelius scored the Cowboys' only touchdown of the second half to make it 38-28.

UP NEXT

Texas: The Longhorns return home to take on No. 13 West Virginia in a game that could wind up being a preview of the Big 12 Championship Game.

Oklahoma State: The Cowboys go on the road to face Baylor, which has lost two straight.

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