Jamie Vardy struck deep into stoppage time to send Leicester through to the last 32 of the Europa League with a thrilling 3-3 draw against Braga in Portugal.
With Zorya Luhansk beating AEK Athens in the other game in Group G, a draw was good enough for the Foxes to seal qualification with two matches remaining.
Their chance looked to have gone after Fransergio restored Braga’s lead for the third time on the night in injury time, but Vardy pounced with 95 minutes on the clock.
Earlier, Harvey Barnes cancelled out Ali Al Musrati opener before Paulinho scored to send the hosts into half-time in front. Luke Thomas netted another equaliser for the Foxes after 78 minutes before the late drama.
Brendan Rodgers made five changes from the side that was beaten 3-0 by Liverpool in the Premier League on Sunday. Hamza Choudhury, Dennis Praet, Thomas, Cengiz Under and Kelechi Iheanacho came in for Wesley Fofana, Youri Tielemans, Nampalys Mendy, James Maddison and Vardy.
A frenetic start to the game saw both teams score in the opening nine minutes. Braga, beaten 4-0 at the King Power Stadium a fortnight ago, took the lead when Al Musrati blasted home a first-time finish from the edge of the box.
The lead did not last long, though, as Barnes squeezed a shot between goalkeeper Matheus and his near post after his overlapping run was spotted by Iheanacho.
Braga restored their lead after 24 minutes when Iuri Medeiros and Ricardo Horta combined to open up the Leicester defence. Paulinho rounded off some lovely one-touch play around the penalty area with a tap-in from close range after Horta had rounded Kasper Schmeichel and set up his team-mate from an acute angle.
A fine one-handed save from Magalhaes to deny Under kept the hosts ahead, but the closing stages of the first half belonged to Braga and Leicester had Schmeichel to thank for keeping them in the match.
The Foxes keeper made a good double save to deny Paulinho and Horta from close range before the former brought another fine stop from the Dane.
Marc Albrighton then switched off as Galeno picked out the run of Nuno Sequeira and his cross was stabbed towards goal by Paulinho, forcing another fine reaction save from Schmeichel.
Leicester survived until the break and looked more assured after the restart. Good play from Tielemans and Albrighton created a chance for Under and his shot forced Matheus into a good one-handed save.
Rodgers introduced Vardy and Maddison from the bench after 62 minutes as he sensed there was something there for his side.
Braga were still a threat, though Schmeichel had to be alert to deny Paulinho once more, this time from a header from Medeiros’ cross.
Leicester were level again with 13 minutes remaining when Thomas turned in Maddison’s driven, low cross to make it 2-2.
However, there was still some late drama to come. Braga went ahead for a third time in injury time. Galeno raced free down the left and breezed past Fofana before releasing a delicate pass to Fransergio, who finished first-time left-footed over Schmeichel.
It looked all over, but Vardy was on hand at the far post deep into injury time to slide in and convert Albrighton’s low cross.