STILLWATER, Okla. (AP) Spencer Sanders fought through pain to deliver a key win for Oklahoma State.
The senior threw for 391 yards and hit Bryson Green with the game-winning touchdown pass with just over three minutes left, and the 11th-ranked Cowboys defeated No. 20 Texas 41-34 on Saturday.
Sanders passed for two touchdowns and ran for 43 yards on 11 carries.
Oklahoma State coach Mike Gundy said Sanders is not at full strength while dealing with undisclosed injuries, making his performance all the more impressive.
''When your quarterback is a very competitive player, he's willing to give his body up, play injured, never says a word, never complains, he just keeps playing, that makes my job easier,'' Gundy said.
Green's 41-yard touchdown came when he caught the ball on a slant, broke out of D'Shawn Jamison's grasp just inside the 35 and made a move on Jerrin Thompson to break into the open field.
Oklahoma State's Jason Taylor II intercepted two of Quinn Ewers' passes for the Cowboys, and Kendal Daniels picked off Ewers in the final minute to end the Longhorns' final threat.
Green had five catches for a career-high 133 yards and Dominic Richardson had three short touchdown runs for Oklahoma State (6-1, 3-1 Big 12), which bounced back from a double-overtime loss to TCU the previous week.
Sanders struggled against TCU, completing just 16 of 36 passes for 245 yards with a touchdown and an interception.
''Coming into this week, I focused on the mistakes that I made last week,'' he said. ''That's out of the way. We just have to make sure every play is a new play; every game is a new game. Can't think about last week. Fix your mistakes and move forward.''
Texas committed 14 penalties for 119 yards while Oklahoma State went without a penalty.
''It's very frustrating because for somewhere in there, we lose focus or mental intensity.'' Texas coach Steve Sarkisian said. ''We just didn't operate very good, and a lot of it was self-inflicted wounds.''
Bijan Robinson ran for 140 yards and a touchdown and caught a 41-yard touchdown pass for Texas (5-3, 3-2). Ewers passed for 319 yards and two touchdowns, but he went 6-for-18 with two interceptions in the fourth quarter.
Texas led 31-24 at halftime as both teams gained more than 300 yards before the break.
The Longhorns gained just 172 yards and nine first downs in the second half.
''Our staff and our players found a way to slow them down a little bit, tackle a little bit better, made adjustments on the counter play and covered pretty good,'' Gundy said.
Sanders' 10-yard touchdown pass to Brennan Presley and the extra point tied the game at 34 with 9:54 remaining in the fourth quarter, setting up the final frantic minutes.
Now, Texas has to deal with having surrendered a 31-17 lead.
''It hurts to the core,'' Texas linebacker DeMarvion Overshown said. ''I'm hurting, everyone in the locker room is hurting. Losing a big game on the road going into a bye week - it's going to sting.''
Texas: The Longhorns had been solid defensively throughout the season, but Oklahoma State made numerous spectacular plays to move the ball. The Cowboys finished with 535 yards against a team that had allowed 347.4 yards per game in its first seven contests.
Oklahoma State: As in the Texas Tech win, the Cowboys improved defensively in the second half and let Sanders, their veteran quarterback, bring it home. Sanders completed nine of his final 13 passes for 107 yards and two touchdowns.
Robinson moved up from 13th to 10th in career rushing at Texas. He entered the day with 2,610 career yards. He passed Eric Metcalf, Hodges Mitchell and Malcolm Brown. He's within 32 yards of D'Onta Foreman for ninth.
FG STREAK ENDS
Oklahoma State's Tanner Brown had made his first 13 field goals this season before missing his second attempt of the game, from 48 yards at the end of the first half. He came back and made a 40-yarder in the third quarter.
Sarkisian said defensive back Anthony Cook suffered a broken arm in the first half. Cook entered the game with 42 tackles, two tackles for loss, two pass breakups and a fumble forced.
Texas visits Kansas State on Nov. 5.
Oklahoma State visits Kansas State on Oct. 29.
Follow Cliff Brunt on Twitter: twitter.com/CliffBruntAP
More AP college football: https://apnews.com/hub/college-football and https://twitter.com/ap-top25. Sign up for the AP's college football newsletter: https://tinyurl.com/mrxhe6f