Marseille were reeling after Samuel Grandsir headed Troyes ahead with just 37 seconds gone at the Stade de l’Aube, but Clinton Njie’s scuffed effort soon pulled the visitors level.
The 41-year-old Benjamin Nivet fired Troyes back in front just after half-time as the veteran skipper followed up a rebound after Yohann Pele had saved from Grandsir.
But a clinical finish from Greece striker Kostas Mitroglou made it 2-2 with quarter of an hour to play, and Thauvin volleyed home his team-leading 17th league goal on 86 minutes to cap a dramatic victory.
Rudi Garcia’s Marseille remain level on points with third-placed Lyon, who occupy the final Champions League spot, while Monaco are four points ahead of the chasing duo.
Marseille could also return to Europe’s elite competition next season by winning the Europa League, where they will face Austrian outfit Salzburg over two legs for a place in the May 16 final.
Paris Saint-Germain will reclaim the French title later on Sunday if they beat reigning champions Monaco at the Parc des Princes.