Fred Peete added 14 points and Cartier Martin finished with 11 for Kansas State (13-5, 3-4), which trailed by just a point with just over 16 minutes to play before the Cowboys used an 11-0 spurt over the next four minutes to take control of the game.
Joey Graham scored 23 points and pulled down 10 rebounds and John Lucas III had 19 points and 10 assists for Oklahoma State (16-3, 6-2 Big 12), which lead by as many as 20 points with seven minutes to go.
The Wildcats, who dropped their eighth straight in Stillwater, never got closer than 15 the rest of the way.
The Cowboys started strong from 3-point range and led 14-7 after back-to-back 3s from Lucas and Jameson Curry.
Kansas State pulled to 19-17 on a driving basket by Peete, but Graham stretched the lead again with five straight points.
Massey scored five in a row to bring the Wildcats to 28-26, before Oklahoma State scored eight of the final 12 points of the half to lead 36-30 at halftime.