London: Olympique Marseille snatched a last-gasp 3-2 victory at Borussia Dortmund to reach the Champions League knockout stages while Chelsea spared themselves an anxious night with a comfortable 3-0 win over Valencia to join them in the last 16 Tuesday.
Zenit St Petersburg also grabbed a place among Europe's elite thanks to a gritty 0-0 draw in Porto.
All seemed lost for Marseille when they trailed the German champions 2-0 after 32 minutes and rivals Olympiakos were beating Group F winners Arsenal in Greece but Loic Remy gave them a lifeline when he scored in first-half stoppage time.
Andre Ayew made it 2-2 after 85 minutes and, with Marseille needing victory to edge out Olympiakos Piraeus, Mathieu Valbuena curled in a sensational winner with three minutes of normal time remaining to send the French side through as runners-up.
Dortmund, who began the night with a remote chance of qualification, finished bottom.
"This win will be engraved in the history of Marseille," coach Didier Deschamps told reporters.
"Football is marvellous when you win. We believed right until the end, both the players and the fans."
Olympiakos had looked like taking second place as they marched toward a 3-1 victory over Arsenal but Marseille's Houdini act means the Greek side have to settle for a place in the last 32 of the Europa League instead.
With nine of the last 16 having already been decided, three of the remaining seven spots were up for grabs in some tension-filled clashes in sections E-H.
Chelsea began their final Group E match at home to Valencia with their hopes balanced on a knife edge, knowing they need a win to be sure of qualifying.
Once Didier Drogba fired them ahead after three minutes, however, the nerves disappeared and Ramires's strike in the 22nd knocked the stuffing out of Valencia who were also vying for second spot.
Drogba, back to his best, struck again in the 76th minute with a neat finish to snuff out Valencia's rapidly fading hopes of snatching a place in the knockout round.
Chelsea manager Andre Villas-Boas said his team's performance was indicative of their recent defensive improvements and the victory was a very good emotional win before next week's Premier League clash with Manchester City.
"Our defense is not that bad and we have been improving a lot," the Portuguese, who has been under the spotlight after a run of poor results, said.
"(There has been) a lot of criticism toward our players and I think they gave everybody a slap in the face today."
Bayer Leverkusen's 1-1 draw at Racing Genk provided an added bonus for Chelsea who go into next week's draw for the last 16 as group winners instead of the Germans, meaning they will avoid the likes of Barcelona, Real Madrid and Bayern Munich.
Former Brazil captain Socrates dies at 57
Genk were on the verge of a first Champions League victory courtesy of a Jelle Vossen volley but Eren Derdiyok equalised late on to safeguard the Bundesliga side's record of never having lost to a club from Belgium.
Zenit's draw in Porto kept them in second place a point above the Portuguese and behind surprise Group G winners APOEL Nicosia whose 2-0 home defeat by Shakhtar Donetsk was academic as they had already become the first Cypriot side to reach the knockout rounds of the competition.
For once the focus was not on holders Barcelona who had reached the last 16 and won Group H last month.
They fielded 10 outfield players with an average age of 21 against BATE Borisov at the Nou Camp but the Catalan club provided a glimpse of the future that will dishearten their rivals at home and abroad.
Teenage midfielder Sergi Roberto opened the scoring and the returning Pedro, the only genuine first-teamer in the side, scored twice in the 4-0 romp which capped an impressive campaign and equalled Manchester United's 1998-99 record of 20 goals in the group stage.
"Having this generation of players and being able to depend on them is very valuable," delighted coach Pep Guardiola, marking his 150th victory in his 208th match as Barca coach, said in an interview with Spanish television.
Already-qualified AC Milan finished distant runners-up behind the Spanish champions, signing off for the winter break with a 2-2 draw at third-placed Viktoria Plzen despite leading 2-0 until the 89th minute.
The remaining four qualifiers for the last 16 will emerge from Wednesday's action in groups A-D when Manchester United and Manchester City are both in danger of missing out.