The West Ham midfielder curled a shot beyond the reach of goalkeeper Fabrice Ondoa just two minutes after the visitors had levelled the match at 2-2.
Blaise Matuidi's volley following a fine run from Kingsley Coman had put the hosts in front before Vincent Aboubakar levelled just two minutes later for a Cameroon side who posed a consistent threat on the break.
Olivier Giroud was booed by some supporters outside the Stade de la Beajouire, with several making their frustrations over Karim Benzema's omission quite clear, but he responded with a fine finish from a Paul Pogba cross for his fifth goal in four starts to put France ahead.
Giroud missed a good chance for a second but was given a largely warm reception when he was replaced by Andre-Pierre Gignac just past the hour, as France began to push forward in earnest in search of a goal to safeguard their third win in a row.
Eric Maxim Choupo-Moting equalised against the run of play in the 88th minute after a Laurent Koscielny error but Payet's superb strike secured a third win in a row for Didier Deschamps' side, who face Scotland on Saturday in a final Euro 2016 warm-up game.
The home side began brightly but Cameroon almost snatched the lead with 13 minutes played, Hugo Lloris forced to make a fine one-handed stop low to his left after Karl Toko Ekambi cut infield and aimed for the far corner.
France went ahead on 20 minutes with their first moment of real attacking quality. Coman skipped away from Edgar Salli down the left and clipped the ball towards the penalty spot, where Matuidi was on hand to volley left-footed past Ondoa.
But the lead lasted just two minutes. Nyom made amends for his earlier sluggish defending by drilling a fine low cross towards the six-yard box, and Aboubakar arrived unchallenged at the near post to turn the ball beneath Lloris.
Pogba spurned a great chance to put France back ahead, flashing a header wide of the right-hand post when unmarked 12 yards out, but Giroud made sure of an advantage before the break.
Juventus star Pogba created space down the right before bending a superb cross towards the penalty spot, and Giroud steered a stylish first-time finish past Ondoa.
Giroud was thwarted by Ondoa just before the hour mark after bustling his way clean through into the penalty area, prompting a few more jeers from sections of the crowd, and Pogba saw a curling effort superbly clawed away by the 20-year-old goalkeeper before N'Golo Kante drilled the rebound wide.
Substitute Cabaye was denied by a sprawling Ondoa when picked out by a fine Payet pass, and they were hit with a sucker-punch a minute later, as Koscielny's slip allowed Choupo-Moting to latch onto Anatole Abang's pass and slot past Lloris.
But Payet had the final word, curling a fantastic free-kick beyond the reach of Ondoa from 25 yards out to secure the win.