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.
|James wants Real Madrid stay, says wife|
|Copa Libertadores Review: Iquique beat Zamora in seven-goal thriller|
|Pochettino hits back at ´enemy´ Xavi over Alli speculation|
|Mourinho: City favourites for top four, not United|
|Sanchez won´t be sold to Premier League rival, insists Arsenal boss Wenger|
|Simeone: Atletico have four finals after Villarreal loss|
|Goals are his life - Chelsea boss Conte delighted to see Costa back on target|
|Puel praises former pupil Hazard after Chelsea defeat|
|Carrasco suffers collarbone injury in Villarreal defeat|
|I have a squad of great men - Conte lauds Chelsea toughness in Southampton win|
|A massive step - Cahill, Hazard confident on Chelsea´s title charge|
|Borussia Monchengladbach 1 Eintracht Frankfurt 1 (aet, 6-7 pens): Hradecky and Hrgota heroes|
|Atletico Madrid 0 Villarreal 1: Late Soriano strike downs Simeone´s side|
|Wolves 0 Huddersfield Town 1: Brown seals play-off spot for Terriers|
|Angers 2 Guingamp 0: Letellier saves hosts from penalty injustice|
|Niasse red card overturned after Hull City appeal|
|Chelsea 4 Southampton 2: Hazard, Cahill and Costa move Conte´s men a step closer|
|Ramos receives one-match ban for Messi foul in El Clasico|
|AFC Champions League Review: Paulinho at the double in Guangzhou Evergrande rout|
|United need Griezmann - Silvestre backs proven goalscorer to emulate Rooney|
|Roma can achieve great things - Serie A club can join Europe´s elite, claims Monchi|
|Mourinho: Manchester derby not about me and Guardiola|
|Cavani extends PSG contract until 2020|
|Amsterdam ArenA to be renamed after Johan Cruyff|
|Surgery all that matters for Ibrahimovic - Mourinho realistic on United star´s future|
|Ibrahimovic should join me in MLS - Schweinsteiger|
|I cannot guarantee anything - Pochettino puts Alli future aside for Spurs title charge|
|Emery expecting full-strength Monaco for semi-final|
|Schweinsteiger has no regrets over Manchester United move|
|Sanchez a slow starter - Wenger|
|Zidane would not change Clasico approach|
|Sahin signs Dortmund contract extension|
|Luis Enrique wishes Barcelona had Madrid´s extra games|
|Ancelotti unhappy with Ribery performances|
|Rooney´s Manchester United future ´doesn´t look good´|
|Bale a doubt for Champions League semis with calf injury|
|Luis Enrique reiterates wish for Messi to end career at Barcelona|
|Tuchel relies on Reus to lead Dortmund past Bayern|
|Hazard not right for Chelsea captaincy|
|Pogba might regret leaving Juventus - Barzagli|
|Wenger in jovial mood over Arsenal future|
|Wenger dismisses Giroud to Marseille talk|
|Xavi expects Guardiola to make Alli move|
|Sanchez would be a good signing for Bayern – Matthaus|
|Hazard in no rush to sign Chelsea renewal amid ongoing Real Madrid links|
|Fernandez rules out Neymar exit, plays down Dybala talk|
|Herrera talks up Manchester derby importance|
|Maradona doubts Argentina World Cup qualification without Messi|
|Messi, Iniesta to renew deals soon – Fernandez|
|Benitez unsure over Newcastle future after promotion|
|Premier League win with Chelsea would be Conte´s greatest moment|
|Toure wants derby day tonic for faltering Manchester City|
|Cech hoping for FA Cup joy against old friends when Arsenal face Chelsea|
|Pescara 1 Roma 4: Salah brace condemns Serie A basement boys|
|Newcastle United 4 Preston North End 1: Perez at the double as Benitez´s men seal Premier League ret|
|Simeone: Atletico had a rough patch in 2016|
|Reo-Coker, Richardson to be offered deals for next season at cash-strapped Granada|
|Osasuna forced to design new kit for Barcelona clash|
|Blind happy to play wherever Mourinho needs him|
|AFC Champions League Review: Al Ain beat Zob Ahan, Al Hilal progress|
|Roma seal deal for Sevilla sporting director Monchi|
|Aguero and Silva train with Manchester City after Wembley injuries|
|Wijnaldum urges Liverpool to keep fighting|
|Conte: FA Cup win over Tottenham will not benefit Chelsea in title race|
|Messi feels Clasico win an important step towards LaLiga glory|
|Inter give Pioli vote of confidence|
|Messi is not selfish – Conte shoots down Fabregas over Hazard advice|
|Allegri: Juventus not perfect yet|
|Zidane has no regrets over playing Bale in Clasico|
|Ibrahimovic is privileged physically - Herrera|
|Lahm desperate for DFB-Pokal glory before retirement|
|Bojan revels in landmark strike against Bayern|
|Schalke laugh off Liverpool interest in Kolasinac, Meyer and Goretzka|
|Lyon ready to ´go crazy´ to keep Lacazette – Aulas|
|Mata could return for Manchester United season finale|
|We´ve let him down – Ramsey wants FA Cup win to repay Wenger|
|Five finals between Monaco and Ligue 1 glory – Falcao|
|Martial ´a new player´ as Mourinho hails Burnley performance|
|Play Man United without a referee? I would prefer that – Toure fury with Wembley officials|
|Czech Republic international Rajtoral dead at 31|
|#Messi500 breakdown: How Clasico winner took Messi to new heights|
|Marcelo: Madrid not inferior to Barca after Clasico loss|
|MLS Review: Larin brace sinks NYC, Dempsey stars for Sounders|
|Clasico hero Messi a blessing for Barcelona, says Iniesta|
|The best player in history – Suarez congratulates Messi|
|Carvajal: Ramos red card defined Clasico and Madrid loss to Barca|
|Messi cannot surprise anyone – Rakitic lauds Barcelona hero|
|Sergio Ramos feels red card was excessive: I did not try to hurt Messi|
|I don´t understand your question - Wenger unsure of impact from semi-final win|
|Giving up is not an option - Injured United star Ibrahimovic vows to return|
|Pique: Ramos will realise he deserves his red once he gets home|
|Zidane: Real Madrid should have been smarter with 10 men|
|Lyon 1 Monaco 2: Falcao and Mbappe make the difference|
|Messi is decisive even when he´s eating dinner at home - Luis Enrique hails Barca star after Clasico|