Kevin Grosskreutz scored in the dying stages as Borussia Dortmund beat Marseille 2-1 to clinch top spot in UEFA Champions League Group F.
Jurgen Klopp's men went into the game knowing that a win would be enough to see them qualify for the next stage, but any sort of slip-up would afford Napoli the chance to progress.
Last season's beaten finalists looked to be on their way to a routine victory when Robert Lewandowski put them ahead in the opening stages.
However, Marseille - managed by sporting director Jose Anigo following Elie Baup's dismissal last week - quickly levelled matters through defender Souleymane Diawara as they sought to avoid the ignominy of finishing the group stage with no points.
Dortmund wasted numerous chances to go back in front in a one-sided second half at the Stade Velodrome, Lewandowski and Marco Reus among those to miss gilt-edged opportunities.
But the Bundesliga club finally breached a stout Marseille defence as Grosskreutz struck three minutes from time to seal top spot as previous group leaders Arsenal were beaten 2-0 at Napoli.
Defender Rod Fanni made his return from injury for Marseille, while Benjamin Mendy and Saber Khelifa were also included in the starting XI by Anigo.
Nuri Sahin recovered from an ankle problem to feature in the Dortmund line-up as Klopp handed starting berths to youngsters Marian Sarr and Erik Durm.
Dortmund took the lead after just three minutes, left-back Durm playing an influential role as he played in Lewandowski with a deft pass, with the Poland striker making no mistake as he coolly lifted the ball over Steve Mandanda.
However, the visitors' hopes of qualification were dealt a blow 11 minutes later when Diawara headed into an empty net after Khelifa had turned Dimitri Payet's superb free-kick against the crossbar.
Dortmund continued to dictate an extremely open game, though, but struggled to create many meaningful chances. Reus went closest just after the half-hour mark when he blazed over the bar following a swift counter-attack.
But the German outfit's fortunes turned shortly after as Payet was dismissed for a second booking in a matter of minutes after referee Marijo Strahonja ruled that the winger had dived in an attempt to win a penalty from a challenge with Sahin.
Marseille remained a threat despite their numerical disadvantage, however, with Andre-Pierre Gignac forcing Roman Weidenfeller into action before Reus spurned another opportunity at the other end prior to the interval.
Anigo's men rode their luck for much of the second period, and they were fortunate not to fall behind on two separate occasions, Reus hitting the post shortly after Mandanda had produced a brilliant far-post save to keep out Jakub Blaszczykowski's header.
Dortmund should have re-taken the lead in bizarre fashion after 66 minutes when Lewandowski intercepted Mendy's backpass, only to hit the side netting after rounding Mandanda.
Klopp's men refused to let up as they heaped further pressure on the Marseille defence, Reus somehow missing the target from point-blank range with the goal at his mercy.
And Dortmund were then denied a penalty in the closing stages after Mandanda collided with Lewandowski, but this proved immaterial as Grosskreutz's effort from the edge of the area snuck into the bottom corner to ensure their progression.
|Newcastle hold talks over Northampton youngster|
|Cuadrado´s agent plays down Chelsea exit rumours|
|Liverpool´s Alberto set for Deportivo loan|
|Leverkusen suffer surprise defeat, Stuttgart hit six|
|Inter ´dismayed´ at Fiorentina vice-president´s Salah Twitter outburst|
|Blaszczykowski ruled out of Dortmund´s Asia tour|
|Gerrard gets the beers in for LA Galaxy fans|
|De Gea coy over Real links|
|Former Brazil star Carlos handed Delhi reins|
|Ciftci will not push through Celtic switch – agent|
|In-demand Mitrovic considering Roma offer|
|Lehmann calls on Cech to ´get over´ Chelsea|
|Marlos double sinks Monaco|
|Mauritius 0 South Africa 2 (agg 0-5): Bafana set up Angola qualifier|
|Keane relishing Gerrard arrival|
|Palace confirm Cabaye interest|
|Hamburg bring in Spahic after head-butt ban|
|Blatter hits out at France and Germany over World Cup votes|
|Sanchez: World Cup exit spurred Chile to Copa glory|
|Jojic makes Cologne switch, Santana move falls through|
|Carrillo keen to get going at Monaco|
|Micronesia thrashed 38-0 as Fiji triumph in Olympic qualifier|
|Schalke stunned by ´machine´ Caicara|
|MLS Review: Keane shines at Gerrard´s Galaxy unveiling|
|Counter-attacking the key for Japan|
|Jimenez happy at Atletico|
|Gerrard predicts ´successful future´ with Galaxy|
|Iniesta can´t see Real selling Ramos|
|Keshi sacked as Nigeria coach|
|Three finals, three defeats for Messi, Mascherano|
|Nani close to Fenerbahce move|
|Sampaoli revels in ´unbelievable joy´|
|Bravo: Copa victory a dream|
|Martino: Argentina should have won|
|Chile 0 Argentina 0 (4-1 on penalties): Hosts end trophy drought|
|Germany 0 England 1 (after extra time): England make World Cup history|
|Kenya 0 Ethiopia 0 (agg 0-2): Hosts sent out of CHAN qualifiers after second penalty miss|
|Dortmund put 17 past Olympians, Bremen hand out thrashing|
|Dinamo Zagreb confirm arrests of coach and club president|
|I didn´t know who Wimbledon guest Klopp was - Brown|
|LeBron James backs Liverpool captain Henderson for FIFA 16 cover.|
|Ramos: I am not negotiating with anyone|
|Valencia complete Mina swoop|
|United States v Japan: US seek final redemption|
|Hanousek consigns Celtic to defeat|
|Roma confirm Dzeko interest|
|Arsenal forward Podolski completes Galatasaray switch|
|Warm Dortmund welcome delights Tuchel|
|Silva vows to fight for Madrid place|
|Mancini hints at Shaqiri and Santon departures|
|Bojan raring to go after return from injury|
|Babel backs Firmino to shine at Liverpool|
|Falcao must wait to impress, warns Chelsea favourite|
|Bartomeu: Deal in place for Turan|
|Parejo re-signs with Valencia|
|MLS Review: Sounders return to winning ways|
|Klinsmann unhappy with USA performance|
|High hopes for Paraguay - Diaz|
|Gareca: More to come from Peru|
|Gerrard had European offers|
|Argentina out to spoil Chile´s party - Martino|
|Sampaoli: Chile won´t change style|
|Di Maria will come good at United - Rojo|
|Peru 2 Paraguay 0: Gareca´s men finish third at Copa|
|United States 4 Guatemala 0: Klinsmann´s men win comfortably|
|´I’d prefer no-one to know my name´ - Bassett|