Dortmund, who beat Olympique Marseille 2-1, Arsenal and Napoli all finished on 12 points with the Bundesliga team topping Group F and the Italians proving the odd team out on head-to-head superiority despite a 2-0 victory over the English Premier League leaders.
Milan had captain Riccardo Montolivo sent off midway through the first half but Ajax could not take advantage and secure the victory they needed to leapfrog the hosts.
Brazil striker Neymar scored a hat-trick, his first Champions League goals, as Barcelona romped to a 6-1 demolition of Celtic to go through as Group H winners.
Galatasaray ended the campaign of Italian champions Juve with a 1-0 success in Istanbul, Wesley Sneijder hitting a late winner in a game re-started on Wednesday following Tuesday's abandonment because of heavy snow.
Zenit St Petersburg and Schalke 04 also progressed.
Zenit created Champions League history by becoming the first team to qualify for the knockout stages with only six points from six matches after a 4-1 defeat at Austria Vienna.
The defeat did not prove costly thanks to Porto's 2-0 defeat at Group G table-toppers Atletico Madrid.
Schalke beat Basel 2-0 to deny the Swiss side second spot in a Group E won by Chelsea who beat Steaua Bucharest 1-0 at Stamford Bridge.