MORGANTOWN, W.Va. -- Leg cramps weren't going to keep Juwan Staten from getting West Virginia to 20 wins for the first time in four seasons on Monday night.
Staten scored 20 points, including a layup with four seconds left, then draped Perry Ellis on the other end after a long pass before the Jayhawks forward missed a layup off the back of the rim at the buzzer as No. 23 West Virginia beat No. 8 Kansas 62-61.
"I might have rushed it a little bit, but I should have made it," Ellis said.
It was a resume-building victory for the Mountaineers (20-6, 8-5 Big 12), who had lost three of their previous four games and four straight against ranked opponents. They're looking for their first NCAA tournament bid in three seasons.
"This was definitely a must-win game at home," Staten said. "We had the crowd behind us and we fought to the end."
With the game on the line, coach Bob Huggins knew who he wanted to give the ball to: Staten, West Virginia's leading scorer and the Big 12 preseason player of the year.
Staten took an inbounds pass and went the length of the court, made a spin move around Frank Mason III and hit the left-handed layup over the outstretched arms of two other Kansas defenders.
It was Staten's first field goal over the final eight minutes after he had gone to the bench with cramps.
"That is exactly how we drew it up," Staten said. "When I spinned, I'd seen nothing in the lane. I laid the ball up. It was a good call by coach."
Ellis finished with 19 points, Mason had 18 and Kelly Oubre Jr. added 14 points for first-place Kansas (21-5, 10-3), whose lead was trimmed to 1.5 games over No. 14 Iowa State.
Jevon Carter, who also played through leg cramps, added 13 points for West Virginia, including back-to-back 3-pointers to put the Mountaineers ahead 60-59 with 2:31 remaining.
"I've got to give a lot of credit to my teammates for setting me up with good passes and good screens leading to open shots," Carter said. "I just dug deep, knocked them in and gave my team the momentum."
Mason made a layup with 2:13 left to give Kansas the lead, but the Jayhawks didn't score again. He missed another layup with nine seconds left and the ball went out of bounds, setting up Staten's heroics.
"He made a nice play, but we couldn't have defended it worse," said Kansas coach Bill Self.
Ellis had 15 points after halftime, capping a 10-0 run to start the second half with a 3-pointer to put Kansas ahead 40-33. But the Jayhawks later went seven minutes without a field goal.
Staten hit a layup and a jumper 50 seconds apart, and Jonathan Holton made a free throw to put West Virginia ahead 50-49 with 7:20 left.
"We had our chances but we just didn't capitalize," Self said. "The end of the game was a perfect example. Jamari makes the best pass of the year, Perry catches it right in stride, has an uncontested layup and basically he just missed the layup."
Kansas: The Big 12's top 3-point shooting team made 6 of 11. ... Wayne Selden, who averaged 16 points over his five previous games, was held to four Monday night.
West Virginia: The Mountaineers led by as many as 11 points in the first half, were ahead 33-30 at halftime and were outscored in the second half for the fifth straight game. ... Devin Williams reinjured his right hand that had been heavily taped in a loss at Iowa State on Saturday. Williams, who had 22 points and 13 rebounds a year ago in a home win over Kansas, finished with eight points and four rebounds.
Huggins admits his team doesn't shoot well consistently, which is why he stresses getting multiple chances on offensive possessions. West Virginia leads the nation with 17 offensive rebounds per game and got 22 on Monday night.
Kansas hosts TCU on Saturday.
West Virginia plays at No. 22 Oklahoma State on Saturday.
Predictions for all 31 college basketball conference tournaments
ESPN.com's college basketball experts pick a winner for all 31 conference tournaments.
College Basketball Power Rankings: Michigan jumps Baylor for No. 2 spot
Kansas' win over Baylor not only means the Jayhawks move up, but also lifts Michigan to the No. 2 spot, just below undefeated Gonzaga.
Sports betting's best of the week: Golden tickets, props, trends and more
From NBA to college hoops, NHL and more, there is plenty going on in the sports world post-football. Doug Kezirian and David Purdum take a weekly look at the sports betting landscape.