Robert Lewandowski's neat chip put Dortmund ahead in the fourth minute but the lead lasted only 10 minutes before Souleymane Diawara headed home an equaliser.
With the score at 1-1 and with Napoli winning against Arsenal, the 2013 finalists looked to be heading out of the competition despite playing against 10 men following the first-half dismissal of OM midfielder Dimitri Payet.
But in the 86th minute Kevin Grosskreutz popped up to fire the German side into the knockout stages.
The result meant Napoli dropped into the Europa League despite their 2-0 triumph over the Gunners in Naples.
Gonzalo Higuain slotted home on 73 minutes to break Arsenal's determined resistance and after Mikel Arteta was sent off for the visitors, it was always going to be an uphill battle to get back into the tie.
Jose Callejon chipped in a second during stoppage time but it was not enough for the Italians as Arsenal also progressed.
Barcelona got the point they needed to finish top of Group H with Neymar scoring a hat-trick in a 6-1 demolition of basement side Celtic.
The Hoops found themselves behind after only seven minutes when Barca defender Gerard Pique opened the scoring from close range.
Pedro Rodriguez and Neymar added further goals before the break and the Brazilian scored his second two minutes after the interval before grabbing his hat-trick before the hour mark.
Substitute Cristian Tello got in on the act in the 71st minute for number six before Georgios Samaras grabbed a late consolation.
Ten-man AC Milan scraped into the knockout stages by resisting an all-out Ajax assault to secure a goalless draw at the San Siro.
The Serie A giants needed a point to ensure second place in Group H ahead of Frank de Boer's Ajax, and Riccardo Montolivo's early dismissal left the Rossoneri playing at a disadvantage for over 68 minutes, with goalkeeper Christian Abbiati drawing on all his European experience to keep the desperate Dutch side at bay.
Chelsea edged out Steaua Bucharest 1-0 to finish top of Group E, but it was a less than convincing performance from Jose Mourinho's side, for whom Demba Ba scored the only goal.
Schalke joined them in the last 16 with two second-half strikes earning a 2-0 home victory over 10-man Basel.
The Swiss side suffered a setback in the 32nd minute when they had defender Ivan Ivanov sent off, and Schalke made the extra man count soon after the interval with goals from Julian Draxler and Joel Matip seeing them through.
Atletico Madrid's impressive campaign continued as they saw off Porto 2-0 in their final Group G game thanks to first-half goals from Raul Garcia and Diego Costa.
Zenit St Petersburg finished runners-up despite losing 4-1 to Austria Vienna.
All seemed rosy for Zenit when Alexander Kerzhakov slotted home in the 35th minute.
However, two goals by Philipp Hosiner and a Tomas Jun strike in the space of eight minutes either side of half-time put the match beyond the visitors with Roman Kienast scoring the fourth in stoppage time.
Wesley Sneijder beat the snow to give Galatasaray a 1-0 win over Juventus that put his side and not the Italians into the last 16.
Resuming their game which was abandoned due to the conditions on Tuesday, the two looked set for a goalless draw which would have sent Juve through in the wake of group leaders Real Madrid.
Sneijder changed all that, though, scoring five minutes from the end to bring the Turk Telecom Arena to life and condemn Juve to the Europa League.