EAST LANSING, Mich. (AP) -- Michigan State started flat and finished sky high.
Brett Swenson kicked a 44-yard field goal with 7 seconds left, lifting the 22nd-ranked Spartans to a 25-24 comeback win over Wisconsin on Saturday.
Michigan State was lackluster for much of the game and seemed headed for a 1-5 record in games following its last six wins against Michigan, but erased an 11-point, fourth-quarter deficit and took its first lead when the game was on the line.
"We were flat and I hate to say that," Spartans coach Mark Dantonio said. "It might've been because we were coming off an emotional win over Michigan after going into the Ohio State game with a lot of emotion, but the important thing is we finished strong.
"Wow. A game like that keeps you alive," he said.
The victory allowed the Spartans (8-2, 5-1 Big Ten) to hang onto hopes of closing the regular season at Penn State -- after hosting Purdue -- with a chance to at least share the conference championship for the first time since 1990.
"Good teams find a way to win those games and that's what we've become," quarterback Brian Hoyer said.
Michigan State is 8-2 for just the second time in four decades and will play in consecutive bowls for the first time since the end of the Nick Saban era in the late 1990s.
The Badgers (4-5, 1-5) might be staying home in the postseason for the first time since 2001 in a year that started with promise.
They began No. 13 in The Associated Press poll and rose to No. 9 with a 3-0 start.
Wisconsin then blew a 19-point, second-half lead against the Wolverines in the Big Ten opener and lost the next three games.
"Obviously this has put them in a very difficult spot if you look to the beginning of the season to where we are now," coach Bret Bielema said.
Just when the Badgers seemed to turn the season around by winning against Illinois and leading the Spartans for nearly 60 minutes, it fell apart.
"Everything is kind of in disarray right now," safety Chris Maragos said.
The Badgers led for the seventh time in nine games before collapsing with physical and mental mistakes, including at least one by Bielema that helped Michigan State start its comeback.
Wisconsin finished with 12 penalties for 121 yards and Michigan State had two for 30.
After the Badgers went ahead by 11 with 9:19 left, they were called for delay of game and Bielema was called for unsporstmanlike conduct to give Michigan State 20 yards on a 64-yard drive for a TD.
"I told our guys after the game, `First off, I apologize for losing the 15-yard penalty myself,"' Bielema said.
The Spartans held Wisconsin to a three-and-out drive and Swenson kicked a 50-yard field goal, then Wisconsin had a chance to seal the victory.
But a holding penalty negated a run to the Michigan State 4 and a first down. Then, a false start pushed the Badgers back to the 40 and led to a punt.
The Spartans had the ball at their 17 with no timeouts and 1:19 left on the game-winning drive.
Hoyer connected with Blair White twice on 20- and 32-yard receptions and his last pass was to B.J. Cunningham over the middle for a short gain with the clock running.
The Spartans scrambled to get lined up for a field goal, but were given a chance to set up because Wisconsin called a timeout with 12 seconds left. The Badgers called their last timeout, hoping to rattle the kicker only to watch Swenson take his helmet off, laugh and make the field goal.
"The first timeout helped me out because it gave me a chance to relax after rushing on the field," Swenson said. "The second timeout, I thought was funny because he was trying to ice me and I knew that wouldn't work."
Swenson was 4-for-4 on field goals, carrying the offense in perhaps the most clutch performance by a kicker in Michigan State history as Javon Ringer was held to a season-low 54 yards and Hoyer completed just 43 percent of his passes and didn't throw a TD pass.
Ringer was about 100 yards rushing short of his average, but did scored two TDs after being slowed by flulike symptoms during the week. Hoyer was 19-of-44 for 252 yards, connecting with White seven times for 164 yards.
Wisconsin's John Clay ran for 111 yards, including a 32-yard TD that gave the Badgers a 24-13 lead early in the fourth quarter, and P.J. Hill had 106 yards rushing and a score that gave them an 11-point lead in the third.
Garrett Graham, making up for the loss of star tight end Travis Beckum, had six catches for 68 yards and the game's first TD.
"We had the game in our hands and we gave it away," Clay said. "It hurts."