Eric Bautheac scored an 81st-minute winner as Nice pulled away from Ligue 1's bottom three with only their second win of the season.
Bautheac's corner had set up the opener for Mahamane Traore, but Salif Sane equalised on the stroke of half-time.
It appeared for a long time as though Nice were destined for their seventh draw in 11 league games this season but Bautheac had other ideas.
Nancy had the first clear-cut chance of the afternoon when Djamel Bakar set up Ziri Hammar, who ran through on goal but saw his shot saved by David Ospina.
But Nice went ahead in the 20th minute, Bautheac's delivery flicked on by Dario Cvitanovich for Traore to fire past unsighted keeper Guy N'Dy Assembe.
Bakar hammered a 20-yard shot against the post but, after Valentin Eysseric went close at the other end, Nancy's equaliser arrived in first-half stoppage time.
Again the goal came from a corner, Yohan Mollo crossing for Sane to head home at the near post.
That goal gave Nancy the momentum going into the second half and they almost took advantage, Lossemy Karaboue drawing a full-length save from Ospina.
The keeper then had to deal with an awkward bounce to save Hammar's 30-yard strike.
Nice took the upper hand again as the half went on, N'Dy Assembe making an excellent save to keep out Bautheac before turning Eysseric's 20-yard effort around the post.
The pressure finally told with a little under 10 minutes remaining when Didier Digard sent substitute Jeremy Pied running free and the summer signing from Lyon cut the ball back for Bautheac to drive low past the keeper.