Nancy climbed off the bottom of Ligue 1 after upsetting Sochaux to claim only their fourth win of the season.
First-half goals from Benjamin Moukandjo and Florent Zitte put Nancy in charge, and Sochaux halved the deficit through Sloan Privat's acrobatic effort in stoppage time at the end of the game.
The victory sees Nancy move above Troyes and to six points behind Sochaux and safety.
Sochaux came into the match on the back of a three-match unbeaten run, which included a victory over league leaders Paris St Germain, but they found themselves trailing just six minutes in after conceding a penalty.
Loic Poujol's handball inside the area gave Nancy the opportunity and Moukandjo made no mistake from 12 yards even though Sochaux goalkeeper Simon Pouplin guessed the right way.
Poujol was also involved in Nancy's second goal six minutes before half-time as his poor clearance was swopped on by Djamel Bakar, who quickly freed Zitte and the 19-year-old showed great composure to take a touch before driving a low shot past Pouplin.
Sochaux threatened only a couple of times before the break, Cedric Bakambu seeing two headers saved by Damien Gregorini, but they almost pulled a goal back 10 minutes into the second half with a Giovanni Sio shot that hit the side-netting.
The hosts continued to push for a way back into the game and they came within inches of managing it in the 85th minute when Sebastien Roudet's right-footed volley smashed against the post.
Sochaux did finally get the goal they had been desperately searching for, but Privet's brilliant overhead kick came three minutes into stoppage time and left the home side too little time to get back on terms.