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.
|Williams rules out Swansea exit|
|UEFA Europa League Preview: Southampton, Vojvodina poised to advance|
|Mitrovic up for a battle|
|Pochettino in the market for a striker|
|Beware of Leverkusen, says Kiessling|
|CONCACAF Champions League Review: Rimando, Plata stand tall for RSL|
|Jardim: Monaco worked on defending lead|
|Deila uninterested in pitch excuses against Qarabag|
|City won´t make top four, says James|
|Clyne eyes Premier League title with Liverpool|
|Dos Santos key to Galaxy´s bid for continental dominance|
|Brazil to play Costa Rica in New Jersey|
|Ajax loss ´sad for Dutch football´ - De Boer|
|United target Bale happy at Real|
|Guardiola furious but Mihajlovic defends De Jong: ´Football isn´t dancing´|
|Champions League top priority at PSG - Di Maria|
|UEFA Champions League Review: Ajax crash out after home defeat|
|Blackpool handed suspended deduction|
|Bayern Munich 3 Milan 0: Guardiola and De Jong lock horns in tunnel|
|Akpom, Ojo and Solanke on the move|
|McClaren: No Newcastle bid for Austin|
|Real Madrid 2 Tottenham 0: Bale on target against former club|
|Mangala vows to improve on debut campaign|
|Tomlin completes Bournemouth switch|
|Astra v West Ham: Page hungry for first-team action|
|Di Maria arrives in Qatar for PSG medical|
|Vitesse v Southampton: Caulker prepared to wait for his chance|
|UEFA rejects Fenerbahce´s Fred appeal|
|Watford show support for assaulted fan as police charge six|
|Ibrahimovic to miss PSG opener|
|Klopp suited to Bayern job - Watzke|
|Eredivisie season-opener postponed due to police strike|
|Dortmund v Wolfsberger: Tuchel set for home bow|
|Griezmann at the double in Atletico win|
|Japan v South Korea: Halilhodzic calls for ´pride´|
|Mourinho enjoying improved relationship with Abramovich|
|Gradel agrees Bournemouth return|
|Inter switch an ´easy decision´ for Miranda|
|Bojan eyes early comeback|
|Vitesse hopeful over Solanke loan deal|
|Pedro will decide his own future - Luis Enrique|
|Iniesta handed Barcelona armband|
|Kukesi punished after Europa League abandonment|
|Leno hints at Leverkusen exit|
|Benitez explains Ronaldo absence|
|Pochettino backs Kane to be among world´s best|
|Messi not ruled out of Mexico friendly - Martino|
|China v North Korea: Kim´s side look for another win|
|River Plate v Tigres UANL: Copa Libertadores final evenly poised|
|Real target Ceballos focused on Betis - Mel|
|Torres: I´d give my life to win La Liga with Atletico|
|Platini can lead FIFA change - Fernandez|
|Mel: Betis won´t be signing Osvaldo|
|Ferrero defends Samp boss Zenga|
|Pochettino expects Spurs improvement|
|Bale ideal for United - Robson|
|Ferdinand: Di Maria will regret United failure|
|Benitez pleased with goalkeepers as De Gea transfer saga continues|
|Guardiola tips fit Schweinsteiger to shine|
|Confident Oxlade-Chamberlain hits back at Keane|
|Ferdinand: Stones would be ´a lunatic´ to join Chelsea|
|Qarabag v Celtic: Gordon wants positivity from Scottish champions|
|Higuain rejects extension from Napoli|
|Zamora returns to Brighton|
|West Ham can cope without Valencia - Gold|
|Wickham loses on Palace debut|
|Guardiola: No problem with Matthaus and Effenberg comments|
|Cartabia excited by Deportivo loan|
|Lyon confirm Rafael deal|
|Hysaj agrees deal to follow Sarri to Napoli|
|Rafael says his goodbyes to Manchester United|
|Dos Santos ready to get going with Galaxy|
|Pochettino rejects Soldado exit talk|
|Metatarsal misery for Mulumbu|
|Benitez: Benzema and Bale going nowhere|
|Mihajlovic: Ibrahimovic would make Milan title contenders|
|Hughes not taking any risks with Bojan|
|Guardiola relishing Audi Cup test|
|Di Maria ´taking a step up´ - Silva|
|Leicester bring in defender Benalouane|
|Deulofeu doubtful for Premier League opener|
|West Ham striker Valencia out for three months|
|UEFA: Qarabag-Celtic to go ahead|
|Palace seal Wickham swoop|
|Ronaldo and Benzema to miss Audi Cup|
|Marotta: Juventus could lose Pogba|
|Kante completes Leicester switch|
|Khedira ruled out for two months|
|FA accepts Mourinho criticism of Wembley surface|
|Robben rubbishes injury talk|
|Marchisio expects Milan title challenge|
|Rafael set for Lyon move|
|Celtic ´seeking reassurances´ over Qarabag pitch|
|Wenger beating Mourinho does not affect Chelsea - Zouma|
|Rooney moved by Everton welcome|
|Mancini not worried by lack of Inter goals|
|Coloccini wants to finish career at Newcastle - McClaren|
|Ramsey: Pressure to win trophies is nothing new|
|Terry: Wembley defeat could be a ´blessing in disguise´|
|Blatter not running for IOC re-election|
|Bendtner: Wolfsburg can challenge Bayern for Bundesliga honours|
|Liverpool relishing Britannia return, says Henderson|
|Everton big enough to keep Stones - Martinez|
|MLS Review: Fire stun Dallas as goals dry up|
|New Atletico signings excite Raul Garcia|
|Cahill expects Arsenal title challenge|
|Jovetic happy with Inter debut|
|Luis Enrique: Barca defence must improve|
|Yanev calls for calm after ugly scenes in friendly|
|Coppa Italia Review: Cittadella romp to victory, Brescia rely on penalties|