The Wisconsin Badgers entered Saturday’s Week 8 game against Illinois with the best defense in the country. But that defense couldn’t make a stop when it mattered most in the fourth quarter as the Fighting Illini handed the Badgers their first loss of the season in an unbelievable comeback victory.

With a 39-yard field goal from James McCourt in the final seconds of the game, Illinois beat Wisconsin, 24-23, putting a huge dent in the Badgers’ College Football Playoff hopes as the Fighting Illini earned their first win over a ranked conference team since 2007, the Big Ten Network noted.

The winning kick also marked the first time Wisconsin trailed all season, and Northwestern had previously scored the most points against it with 15. The Badgers’ defense also shut out four of their first six opponents only to fall apart in Champaign on Saturday.

DOWN GOES NO. 6 WISCONSIN! The first time the Badgers trail all year comes at the hands of @IlliniFootball. James McCourt wins it: pic.twitter.com/r4WwNMWe0h — Big Ten Network (@BigTenNetwork) October 19, 2019

McCourt’s game-winning kick was made possible thanks to two crucial plays late in the fourth quarter.

First, quarterback Brandon Peters threw a perfect pass to wide receiver Josh Imatorbhebhe in the end zone for a 29-yard touchdown, which brought Illinois within two points with just shy of six minutes left with the extra kick.

You might want to get to BTN ASAP. @IlliniFootball pulls within 2 of No. 6 Wisconsin with a late TD: pic.twitter.com/RdAvGlo1S3 — Big Ten Network (@BigTenNetwork) October 19, 2019

And then Illinois’ defense stepped up on the next possession, frustrating Wisconsin and picking off quarterback Jack Coan with 2:32 left in the fourth quarter.

THINGS ARE HAPPENING IN CHAMPAIGN 🔥 pic.twitter.com/E7MxlEquZQ — Big Ten Network (@BigTenNetwork) October 19, 2019

Illinois coach Lovie Smith drained the clock on his team’s subsequent drive to set up the 39-yard field goal with no time left.

The Badgers had a surprisingly slim 13-7 halftime lead and extended it to 20-7 early in the third quarter. But they missed a field goal, lost a fumble and then had that late interception as Illinois continued to find the end zone.

"Our program, we needed to get a signature win. I was just hoping today was the day, and the day came." – @LovieSmith, on @IlliniFootball's upset vs. No. 6 Wisconsin, its first B1G win vs. a ranked team since 2007 pic.twitter.com/kmi4TdrYrR — Big Ten Network (@BigTenNetwork) October 19, 2019

Previously undefeated, Wisconsin had a 33 percent chance to make the College Football Playoff after Week 7, but this loss puts Minnesota in control of the Big Ten West.