Gray (6-1) struck out eight and kept Longhorn runners at bay despite giving up a season-high seven hits in 6 2/3 innings to earn a rare win on Texas' home field.
"I felt kind of funny the whole game," Gray said. "It was my mechanics that were off and I just did a bunch of different things to tweak it and get back. The whole game was a grind and I just had to find a way to win."
Faced with a bases loaded, one-out situation in the bottom of the sixth, Gray punched out Alex Silver with his 100th pitch and then forced a 4-3 groundout to Brooks Marlow.
"In a situation like that you just have to bear down and make good pitches and hope for the best," Gray said.
Gray's performance helped Oklahoma (26-5, 6-1 Big 12) capture just its second win in its last 19 games on Texas' (16-12, 2-5) home field.
"I thought the sequence in which (Gray) located the fastball and the breaking ball to those two hitters was the best he had all night," OU head coach Sunny Golloway said. "And he did it with bases loaded and one out. He had it in him and it was mental toughness that pulled him out."
It was Gray's third game in eight appearances to finish without allowing an earned run. The Sooners' ace has 71 strikeouts to just 34 hits in 60 1/3 innings this season.
Texas starter Parker French (3-2) lasted until the sixth inning. Kolbey Carpenter's knock bounced off the outstretched glove of third baseman Erich Weiss and French followed the play with a five-pitch walk Hector Lorenzana to end his night.
Anthony Hemerlyn singled off reliever Ty Marlow to score Carpenter and give the Sooners their game-winning run.
Neither team would put a runner in scoring position after the starters exited.
"I thought it was a well-played ball game," Golloway said. "I thought there were some great defensive plays made tonight. Again, the pitchers -- their bullpen matched our barrels and our bullpen matched their barrels.
Oklahoma scored in the opening frame as center fielder Craig Aikin crossed the plate following a Matt Oberste sacrifice fly.
It was the team-leading 40th RBI of the season for Oberste, who finished 0-for-3 from the plate, ending his school record and season-long 30-game hitting streak.
Oklahoma and Texas meet for game two of the series Saturday at 2:30 p.m. The contest will be televised on FSN.