Ejim provided 13 points, including a key basket with 3:01 remaining, as Iowa State (19-5, 7-5 Big 12) overcame a blown lead with a 9-2 run to finish the contest.
DeAndre Kane and Georges Niang netted 17 points apiece to help the Cyclones rebound from a 25-point loss to West Virginia Monday.
Naz Long came off the bench to provide 14 points.
Jaye Crockett pumped in a personal-best 23 for the Red Raiders (13-12, 5-7), who erased an 18-point deficit but ultimately came up short.
Toddrick Gotcher contributed 14 points.
Senate Democrats to pull all-nighter on climate change
Scarlett Johansson steps out with fiance after pregnancy reveal