MADISON, Wis. (AP) Wisconsin interim coach Greg Gard likes to say experience is a great teacher.
Maybe that means the Badgers have learned something after coming up just short in games against the likes of Maryland, Indiana and Marquette.
Whereas Wisconsin fumbled away late opportunities in recent close losses, this time Ethan Happ scored underneath with 10 seconds left as the Badgers beat Michigan State 77-76 on Sunday.
Coming in, Wisconsin had lost its four Big Ten games by an average of less than four points, including a painful loss to the Terrapins Jan. 9, as Melo Trimble hit a last-second 3-pointer.
''We were just a little bit better in each possession,'' said Gard, who won his first game against a ranked team since taking over last month. ''Did we play any differently? No. We were still trying to do the same things. But we were a little bit better in how we executed at certain times.''
The Badgers (10-9, 2-4 Big Ten) looked on the verge of letting another one slip away after Denzel Valentine hit a runner to put the Spartans (16-3, 3-3) up 76-72. The Badgers may have faltered in the clutch before, this time they delivered.
Bronson Koenig, who scored 27 points, hit a 3-pointer with Valentine in his face that pulled Wisconsin within 76-75 with 27 seconds left.
The Badgers then went to a full-court press for the first time in the game, forcing a turnover as Eron Harris stepped out of bounds while double-teamed.
Koenig then found Happ underneath the basket. The 6-foot-9 forward briefly bobbled the ball in heavy traffic, spun out from underneath the hoop and hit the winning shot.
The Spartans had a final chance to win, but Valentine missed a 3-pointer and Matt Costello's last-second side jumper bounced off the rim.
Happ said the difference Sunday was the Badgers avoided the last-minute lapses that doomed them in close losses.
''We played together the whole 40 minutes, and it showed,'' said Happ, who had 14 points and eight rebounds while Nigel Hayes added 25 points for the Badgers.
Michigan State's Tom Izzo called it one of the strangest games he's ever coached. The Spartans shot a higher percentage than Wisconsin from the field (48-45), 3-point range (44-43) and outrebounded the Badgers 35-25, but still lost.
Part of that is Wisconsin thrived at the free throw line in a game where 43 fouls were called, 28 on the Spartans. Wisconsin, which was already in the double bonus with more than 7 minutes left in the second half, ended up 29 of 36 from the line while Michigan State was 12 of 16.
Izzo said he was not going to complain about the fouls, pointing instead to his team's failure to execute. For example, he said the ball was supposed to go to Valentine rather than Harris when Wisconsin pressed and caused the late turnover, while Michigan State also failed to rotate properly as Happ got open for the winning shot.
Valentine led Michigan State with 23 points, while Costello added 18.
''It was hard to play,'' Izzo said of the fouls called. ''But that had nothing to do with missing the five or six layups we missed. Layups. Hard to condemn anything else or anyone else.''
Michigan State: 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. ... Izzo said Nairn is dealing with plantar fasciitis and he has no timeline for the point guard's return.
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.
This copy restores dropped word `each' in 5th paragraph.