MADISON, Wis. (AP) -- Ethan Happ scored underneath the basket with 10 seconds left and Wisconsin beat No. 4 Michigan State 77-76 on Sunday.
The Spartans had a final chance to win but Denzel Valentine missed a 3-pointer and Matt Costello's last-second side jumper bounced off the rim.
Bronson Koenig scored 27 points and Nigel Hayes added 25 for the Badgers (10-9, 2-4 Big Ten), who trailed 76-72 after Valentine hit a runner for the Spartans (16-3, 3-3). Koenig hit a 3-pointer with Valentine in his face and the shot clock winding down to pull Wisconsin within 76-75 with 27 seconds left.
The Badgers went to a full-court press for the first time in the game, and forced a turnover as Eron Harris stepped out of bounds while double-teamed.
With the clock winding down, Koenig found Happ for the winning basket.
Valentine led Michigan State with 23 points, while Costello added 18.
The Badgers thrived at the free throw line in a game with 43 fouls called, 28 on Michigan State. Wisconsin was already in the double bonus with more than 7 minutes left in the second half and ended up 29 of 36 from the line while Michigan State was 12 of 16.
The win is Wisconsin's first against a ranked team since interim coach Greg Gard took over in mid-December and it snapped a three-game conference losing streak.
Michigan State: Coach Tom Izzo shook up the starting lineup after Thursday's 76-59 loss to Iowa and point guard Tum Tum Nairn out with a foot injury. Matt McQuaid started for Nairn, with fellow freshmen Harris and Deyonta Davis replacing Bryn Forbes and Gavin Schilling, who had started the previous four games. Schilling entered the game less than 2 minutes in and finished with two points, while Forbes saw his first action a little more than 3 minutes into the game and scored 12.
Wisconsin: The Badgers can only hope Sunday's win sparks them like the last time they were .500 in January and faced Michigan State. That season, Bo Ryan's first at the helm, Wisconsin beat then-No. 25 Michigan State on the road as the Badgers won 10 of 13 to grab a share of the Big Ten title.
Michigan State hosts Nebraska on Wednesday.
Wisconsin travels to Penn State on Thursday.