Valbuena’s 87th-minute effort secured a 3-2 win to ensure Didier Deschamps’ men join Group F winners Arsenal in the knockout stage.
OM looked to be heading for the Europa League as they trailed 2-0 at half-time while Olympiacos – just a point behind Marseille at kick-off – were comfortably beating a below-par Arsenal 3-1 in Greece.
Jakub Blaszczykowski and Mats Hummels put Dortmund in front at the break but Loic Remy and Andre Ayew drew Marseille level before Valbuena snatched second place for his side in the most dramatic of circumstances.
With qualification from Group G already assured, APOEL Nicosia fell to their first loss and handed eliminated opponents Shakhtar Donetsk their first win, with a 2-0 success for the Ukrainians in Cyprus.
Luiz Adriano and Evhen Seleznev scored in the second half for Shakhtar, but despite the defeat APOEL still progressed as group winners after Zenit St Petersburg battled out the goalless draw they required at FC Porto to join them in progressing.
With Group H already decided, reigning champions Barcelona strolled to a 4-0 win over BATE Borisov with two goals for Pedro including a second-half penalty, and a goal each for Sergi Roberto and Martin Montoya.
Europa League-bound Viktoria Plzen fought back for a dramatic 2-2 draw against runners-up AC Milan. Alexandre Pato and Robinho put the Italians in front before Plzen scored two in the last two minutes from David Bystron and Michal Duris.
Leverkusen were overtaken for first in Group E after Robin Dutt’s men were surprisingly held to a 1-1 draw by Genk in Belgium.
Eren Derdiyok’s late strike helped the visitors avoid defeat after Jelle Vossen’s first-half opener, but it left Leverkusen having to settle for second place, with Valencia heading into the Europa League.