Byron Eaton had 16 points and seven assists for Oklahoma State (22-10), which snapped a five-game losing streak against Oklahoma (27-5) and all but clinched an NCAA tournament berth.
Blake Griffin had 17 points and 19 rebounds for Oklahoma, but was whistled for fouling Anderson as several players tussled for a rebound after a missed shot by Eaton in the final seconds.
After Anderson's free throws, Griffin caught a long pass from Taylor Griffin, but missed a well-guarded 3-point attempt. Tony Crocker missed a follow shot.
Connecting you to your favorite North Texas sports teams as well as sports news around the globe.
The clock didn't start until after Blake Griffin's shot, and officials used television replays to determine that time had expired, giving Oklahoma State the win.
The loss probably cost Oklahoma a chance at a No. 1 seed in the NCAA tournament.
While Oklahoma and Oklahoma State regularly meet at neutral sites within the state in other sports, most notably baseball, it's a rare occurrence in basketball. Thursday's game was only the third time in 215 meetings the Bedlam rivals had met in Oklahoma City, and the first time since 1942.
The teams hadn't met in the postseason since 1999, when they played in the Big 12 tournament in Kansas City, Mo.
The lead traded hands four times in the final 2:48. Eaton broke a 68-68 tie by making 1-of-2 free throws with 29.8 seconds left. Crocker caught a lob from Willie Warren and scored with 14.2 seconds left to give the Sooners a 70-69 lead.
Eaton missed while trying to finish a drive, and Blake Griffin was called for a foul on the rebound.
Freshman Keiton Page scored 15 points for Oklahoma State, while Harris had 13 and Obi Muonelo had 12 as the Cowboys won despite being outrebounded 39-29.
Warren and Austin Johnson each scored 13 points for Oklahoma.
Oklahoma State dealt with foul trouble much of the game, as forward Marshall Moses picked up two quick early fouls while defending Griffin and received his fourth with 17:26 left. At the 13:50 mark, Anderson, the Cowboys' leading scorer, was whistled for his fourth foul, and he joined Moses on the bench.
But he did so with Oklahoma State in the midst of a 9-0 spurt, fueled by seven points from Eaton, that gave the Cowboys their biggest lead to that point, 49-41 with 13:26 left. A layup by Terrel Harris extended the margin to 54-45 with 11:12 left.
But the Sooners rallied to tie the game at 56-56 with 9:27 left behind Warren, who had a three-point play, then assisted Juan Patillo on another three-point play and Crocker on a 3-pointer during an 11-2 run.
Anderson and Moses returned with 4:35 left and the Cowboys nursing a 64-62 lead, but Moses fouled out at the 3:44 mark and was slapped with a technical foul for expressing his displeasure with the call.
Blake Griffin had 11 first-half points, all but two in the final 8:23, as the Sooners took a 34-33 halftime lead despite committing 10 turnovers. Oklahoma State went 6-of-15 from 3-point range and Muonelo scored 10 points in the half.