Pierre-Emile Hojbjerg broke away to finish emphatically in the fifth minute of injury time, sealing a Spurs comeback that means they progress as Group D winners while Marseille are eliminated from Europe altogether.
Clement Lenglet had earlier headed the Premier League side back on level terms after a Chancel Mbemba goal gave Marseille the lead at the break.
Hojbjerg's last-gasp strike allowed Antonio Conte's team to leapfrog Eintracht Frankfurt, who also advance after a 2-1 win away to Sporting Lisbon.
It was a pulsating contest at the Velodrome and it could have gone either way, with Marseille left to regret a crucial late miss by substitute Sead Kolasinac.
Had he scored rather than sent a back-post header wide, Marseille would have gone into the last 16. Instead, Hojbjerg's late strike condemned them to the bottom spot in the section.
The result was earned in adversity for the Premier League side, who were without the presence on the touchline of the suspended Conte and also lost Son Heung-min to a head injury in the first half.
"It was very difficult in the first half but we didn't lose our minds, we stayed in the match," said Tottenham assistant manager Cristian Stellini.
"It was terrible the goal we conceded because it came from a corner that was taken quickly and we were not prepared.
"This is an important lesson for the future, but in the second half something changed and we played a fantastic second half."
Hojbjerg's late strike sparked scenes in stark contrast to a week ago when Spurs were denied victory over Sporting after VAR ruled out Harry Kane's last-gasp goal.
That meant Tottenham travelled to France still requiring a point to secure qualification, while Conte was serving a ban after being shown a red card in the aftermath of the Sporting draw.
The visitors' preparations had also been disturbed after Marseille fans let off fireworks outside their hotel in the early hours of Tuesday in an attempt to deprive their rivals of precious sleep.
However, the atmosphere inside Marseille's raucous stadium was a little less boisterous than usual because the whole north end of the Velodrome was shut as a punishment by Uefa following trouble at their earlier group game against Frankfurt.