Late Nivet goal stuns high-flying Marseille
Nivet, who came off the bench at half-time, beat goalkeeper Steve Mandanda following a corner-kick with two minutes to go to give his side their first victory of the season.
Marseille won their first six league matches but have taken just one point from their last three
"We did not do everything we had to. It is a good lesson," Marseille defender Rod Fanni told French channel Canal+.
Nivet, who was playing his 250th French league game, had an earlier opportunity 10 minutes after the break but his header struck the woodwork.
Marseille, who lost striker Andre-Pierre Gignac because of a broken left foot after 23 minutes, had several efforts on target but keeper Yohann Thuram-Ulien denied Mathieu Valbuena's curled free-kick and Charles Kabore's powerful strike in the second half.
Earlier, Olympique Lyon moved up to third on 18 points behind Marseille with a 1-0 win over Stade Brest 1-0 thanks to a fine lob from Bafetimbi Gomis.
Gomis scored a deserved goal for Lyon in the 57th minute when he lobbed goalkeeper Alexis Thebault from a neat Steed Malbranque pass.
The hosts dominated throughout the match but struggled to hit the target with a Jimmy Briand header striking the crossbar on 33 minutes until Gomis earned them a deserved victory.
Ajaccio drew 0-0 home with Bastia in a tense Corsican derby marred by incidents on and off the pitch.
The two sides were reduced to 10 men each after a mass brawl followed a tough challenge for the ball between Gael Angoula and Johan Cavalli, who were both dismissed seven minutes from time.
The referee had to stop the game for five minutes as the tension spread to the stands where both teams's fans threw fireworks.
Bastia are 12th on 11 points, one ahead of 13th-placed Ajaccio.