Spartak won 1-0 at Legia Warsaw to secure an automatic last-16 berth while Napoli face a playoff against one of the third-placed teams in the Champions League dropping into Europe's second-tier competition after the winter break.
Third-placed Leicester go into the third-tier Europa Conference League where they will enter a playoff with one of the competition's runners-up for a last-16 berth.
Adam Ounas fired Napoli into a fourth-minute lead with a crisp low shot and the Serie A side appeared to be in cruise control after Eljif Elmas made it 2-0 with a tap-in after unselfish work from Andrea Petagna.
Sloppy defending cost the home twice in quick succession before halftime, however, as Jonny Evans drilled in a loose ball in the 27th minute and Kiernan Dewsbury-Hall volleyed in the equaliser with his first goal for Leicester.
Spartak, who edged Napoli to top spot with a superior head-to-head record, advanced after their goalkeeper Alexander Selikhov saved a stoppage-time penalty with forward Zelimkhan Bakaev netting a 17th-minute winner at Legia.
Bakaev curled in a fine low shot from the edge of the penalty area but it was Selikhov who emerged as Spartak's hero, parrying Tomas Pekhart's spot-kick which would have knocked the Russian side out had the Czech forward scored.
Mikel Oyarzabal fired Sociedad ahead with a 43rd-minute penalty and added the second before Alexander Soerloth netted in stoppage time to complete a comfortable victory.