By LUKE MEREDITH
AP Sports Writer
AMES, Iowa (AP) -- Three straight losses and the distraction caused by the ongoing Bubu Palo saga left No. 16 Iowa State in desperate need of some good news.
A close win over a ranked opponent was a good place for the Cyclones to start.
Melvin Ejim scored 20 points and Iowa State beat No. 22 Kansas State 81-75 on Saturday to snap a three-game losing streak and get back to .500 in the Big 12.
"I wanted to see how our guys responded, and we had as good a week of practice as we've had all year," Iowa State coach Fred Hoiberg said. "Guys put those losses behind us. They wanted to come out and win in the worst way."
Georges Niang had 18 points and freshman Matt Thomas matched a career high with 14 for the Cyclones (15-3, 3-3 Big 12), who blew a 12-point halftime lead before putting the game away late in the second half.
Ejim blocked a potential game-tying 3 from Shane Southwell and hit two free throws to put the Cyclones ahead 79-73 with 23 seconds left.
Freshman Marcus Foster scored 20 points for Kansas State (14-6, 4-3), which lost consecutive games for the first time since November.
Thomas Gipson had just four points for the Wildcats.
"We had our opportunities. Again, we battled. They're a good team. We knew it would be tough to win here after they had lost three in a row," Kansas State coach Bruce Weber said.
Kansas State spent much of the afternoon allowing Iowa State to make a run and then matching it.
In the end, the Wildcats were just a couple of plays short.
Kansas State needed less than 7 minutes to erase a 46-34 first-half deficit, but Iowa State's inconsistent defense let it down. The Cyclones allowed nine points in 2 minutes, and Will Spradlin's 3 tied it at 66-all with 5 minutes left.
Niang answered with a crucial 3, and Cyclones star DeAndre Kane shook off a sluggish game with a three-point play to put Iowa State ahead 72-66.
Kane finished with 10 points -- his lowest total since mid-December -- after shooting 3 of 12 for the second straight game.
"I think he's rushing it a little bit," Hoiberg said of Kane. "He's a great finisher and he's been showing that all year. But he's struggling with that a little bit right now."
This was the first time in the 216 meetings between Iowa State and Kansas State that both were ranked in the AP Top 25.
But the Cyclones and Wildcats entered play looking to regain some lost momentum.
Iowa State had opened the season at 14-0, the best start in school history. But losses to Oklahoma, Kansas and Texas had considerably cooled the program's national buzz and sent it tumbling eight spots in this week's poll.
Then last week, a district court judge ruled that Palo, a reserve guard who averaged 2.8 points a game last season, be reinstated in a move that angered the administration and dominated local headlines.
Palo had been kicked off the team in August in connection with sexual assault charges that were eventually dropped. The Iowa Supreme Court on Friday denied a request by the Iowa Board of Regents for an immediate stay of that ruling.
Palo spent the game on the bench and in uniform, but Hoiberg refused to comment on Palo after the game.
Kansas State was coming off a buzzer-beating loss at Texas, as Jonathan Holmes hit a 3 as time expired for a 67-64 Longhorns' win on Tuesday.
The Wildcats started out hot from the perimeter, hitting four of their first five 3-point attempts. Iowa State was even better, as the once-struggling Thomas connected on his first four 3s to help give Iowa State its 12-point halftime edge.
"We were getting loose balls. We were getting after them on the defensive end and playing with energy. I think when we do that we're a tough team to beat," Niang said.
Southwell had 14 points and Spradlin added 12 for Kansas State, which hosts Texas Tech and travels to West Virginia next week.
"It's a gut check week for our guys coming up," Weber said. "I told them before the game. `We're a good team. Do you want to be a really good team? That's the question."'
Copyright 2014 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.