Geoffrey Dernis grabbed a dramatic injury-time winner after Brest looked to have been denied victory at the Stade Francis-le-Ble.
Eden Ben Basat gave the home team an early lead but Mounir Obbadi's solo goal levelled matters midway through the second half.
It looked as though that was how it would stay but deep into stoppage time, Dernis fired home to send the home fans into raptures.
Full-back Bernard Mendy was the architect of Brest's 10th-minute opener, counter-attacking down the right before he and Benoit Lesoimier combined to set up Ben Basat who fired home at the near post.
And Mendy was quickly into the action at the other end, clearing off the line after Benjamin Nivet set up Mohamed Yattara to fire at goal.
Kamel Chafni volleyed just wide for Brest after Richard Soumah's free-kick was only half-cleared.
And Troyes had a chance to equalise just before half-time through a volley of their own. Julien Faussurier crossed to Yattara, whose effort almost looped over Alexis Thebaux but the keeper showed sharp reflexes to block it.
The overlapping Faussurier was integral to his side's first attack of the second half, crossing for Sebastien Grax whose header was saved by Thebaux.
The busy home keeper was next brought into action by Granddi Ngoyi, who was set up by Obbadi and Nivet but saw his ferocious drive tipped on to the crossbar.
Troyes were not to be denied and in the 65th minute, Nivet found Obbadi who beat three defenders before beating Thebaux with a powerful low finish.
The game appeared to be petering out into a draw but with the 90 minutes long since up, substitute Charlison Benschop set up Dernis to fire past keeper Yohann Thuram-Ulien for a raucously received winning goal.