STILLWATER, Okla. (AP) — Texas did it to Oklahoma State again.

Ryan Bailey kicked a 40-yard field goal as time expired to lift the Longhorns to a 38-35 victory Saturday and cap another wild comeback by Texas against the Cowboys.

For the second straight week, Jamaal Charles led a late charge for the BCS 15th-ranked Longhorns. He scored two of his three touchdowns in the fourth quarter as Texas outscored Oklahoma State 24-0 in the final 15 minutes.

The Longhorns twice trailed by 21 points, including a 35-14 deficit entering the fourth quarter. It’s the fourth time in five years Texas (8-2, 4-2 Big 12 Conference) has staged a big rally to beat Oklahoma State (5-4, 3-2).

In 2003, Oklahoma State led 16-7 in the first quarter but Texas won 55-16. That was nothing compared to what was to come in this rivalry.

In Austin in 2004, Oklahoma State sprinted to a 35-7 first-half lead before Texas roared back for a 56-35 win. In 2005 — the season Texas won the national title — the Longhorns trailed 28-9 in the first half in Stillwater, but rallied to win 47-28 behind Vince Young.

This time Charles, who scored three fourth-quarter touchdowns in a comeback win over Nebraska last week, was the star.

He scored on a 17-yard run with 11:40 left and reeled off a 75-yard touchdown jaunt with 7:30 left, pulling the Longhorns within 35-28. Charles finished with 16 carries for 180 yards.

A 60-yard pass from Colt McCoy to Jordan Shipley led to a 1-yard touchdown run by Vondrell McGee that tied the game with 3:22 left. Oklahoma State kicker Jason Ricks sent a 34-yard field-goal attempt wide right with 1:13 left.

McCoy, who finished 20-of-27 passing for 282 yards, guided the Longhorns into position for Bailey’s game-winner.

The Cowboys dropped to 2-23 against the Longhorns.

The Cowboys lost this time despite rolling up 594 yards of offense. Zac Robinson finished 30-of-42 passing for a school-record 430 yards and two touchdowns and ran for another score.

Oklahoma State led 14-0 less than three minutes into the game on on a 4-yard run by Dantrell Savage and Jacob Lacey’s 39-yard interception return. Lacey finished with three interceptions.

Between the first and second quarter, a livid Texas coach Mack Brown gathered his players in a huddle and screamed at them.