In a dramatic climax to one of the tightest groups in Champions League history, Borussia Dortmund needed an 87th-minute goal at Marseille to advance at the expense of Napoli which beat Arsenal.
Dortmund, last season's beaten finalist, were on the brink of elimination and missed a series of chances against the 10-man French side until Kevin Grosskreutz scored to clinch a 2-1 win.
Instead, Dortmund won the group ahead of Arsenal, which lost 2-0 to Napoli as all three teams finished on 12 points and head-to-head tiebreakers sent the Italians out.
"What a feeling! We were almost out of the competition. This is great. We deserved it. And I didn't even hit the ball right," said Grosskreutz, who was born and raised in Dortmund.
cling to a draw
On a tense day for Italian clubs, AC Milan advanced by clinging on for a 0-0 draw at home to Ajax after captain Riccardo Montolivo was sent off in the 22nd minute.
Juventus exited in the afternoon after Galatasaray scored late to win 1-0 in atrocious weather and pitch conditions in Istanbul. The match had resumed after being abandoned in snow and hail on Tuesday evening.
Barcelona's progress was smooth and easy as Neymar scored three in a 6-1 rout of Celtic, ensuring the Spanish champion won Group H ahead of Milan to be seeded in the draw on Monday.
Schalke beat Basel 2-0 to finish runner-up behind Group E winner Chelsea, which beat last-placed Steaua Bucharest 1-0.
Germany will have four teams in the last-16 draw for the first time, and England also has its full quartet remaining. Italy has only Milan, confirming the recent slump of Serie A clubs in Europe's top competition.
Zenit St Petersburg advanced with the worst record, stuck on just six points - six fewer than Napoli - after losing 4-1 at Austria Vienna.
In Monday's draw, seeded teams cannot play a team from their own country or the team it already played in the group.
Seeded teams: Manchester United, Real Madrid, Paris Saint-Germain, Bayern Munich, Chelsea, Borussia Dortmund, Atletico Madrid, Barcelona.
Non-seeded teams: Bayer Leverkusen, Galatasaray, Olym-piakos, Manchester City, Schalke, Arsenal, Zenit St Petersburg, AC Milan.