Roach, working the clock 30 feet from the basket on a possession that began with 18 seconds to play, found his way to the rim while being double-teamed to make the winning layup.
The game seesawed between the two teams at the end, with seven lead changes in the final 2:09.
Dylan Osetkowski led the Longhorns (17-12, 7-9 Big 12) with 13 points and nine rebounds while Roach and Jacob Young added 12 each and Jericho Sims hit for 11 points for Texas, which has won two of its past three games.
Jeffrey Carroll paced the Cowboys (16-13, 6-10) with 19 points with Lindy Waters III adding 14 and Kendall Smith scoring nine, seven of which came in the final three minutes. Mitchell Solomon grabbed 10 rebounds for Oklahoma State, which has lost three of its past four games.
Texas played without guard Eric Davis Jr., who will not be allowed in game action while the school conducts an internal investigation into a Yahoo Sports report alleging Davis received $1,500 in advance payments from ASM Sports. The school announced the suspension on Friday.
The Longhorns' Mohamed Bamba sat out the second half because of a left toe injury. He scored just two points on a tip in and grabbed four rebounds in 15 minutes of court time in the first half.
The Longhorns led 33-28 after a first half in which after both teams shot around 36 percent. Oklahoma State scored the first seven points of the game but Texas roared back to lead by eight in the waning seconds of the half.
Carroll paced the Cowboys with 10 points in the first half while Jericho Sims and Osetkowski led Texas with seven points.
Oklahoma State began the second half with eight straight points and that started a 16-2 run that granted it a 45-35 lead with 15:06 to play in the game. But the Longhorns answered with a 17-6 run of their own to tie the contest at 52 with 6:56 remaining and to set the table for the furious finish.
Both teams have two regular-season games remaining. Texas travels to No. 8 Kansas on Monday and then hosts No. 21 West Virginia on March 3. Oklahoma State plays at Iowa State before closing the regular campaign at home versus Kansas on March 3.
--Field Level Media
Oklahoma State | Texas | |
Jeffrey Carroll 19 | Scoring | Dylan Osetkowski 13 |
Brandon Averette 3 | Assists | Kerwin Roach II 5 |
Mitchell Solomon 10 | Rebounds | Dylan Osetkowski 9 |
Jeffrey Carroll 3 | Free Throws Made | Dylan Osetkowski 4 |
Jeffrey Carroll 1 | Steals | Mohamed Bamba 2 |
Mitchell Solomon 2 | Blocks | Jericho Sims 2 |
Team | Points | FG% | 3PM-3PA | FTM-FTA | Assists | Rebounds | Blocks | Steals | Turnovers |
Oklahoma State | 64 | 37.9 | 9-26 | 11-13 | 9 | 33 | 3 | 4 | 9 |
Texas | 65 | 41.1 | 6-20 | 13-20 | 7 | 34 | 2 | 6 | 8 |