The clock showed 99 minutes and 55 seconds when replacement flanker Chouly dotted the ball down after nine penalty scrums, and Camille Lopez slotted over the conversion as France saved their place in the second pot ahead of the 2019 World Cup draw.
Wales had victory in their sights when Leigh Halfpenny's sixth penalty gave them a 18-13 lead but France won a five-metre penalty scrum with one minute left.
Eight scrums later, after Wales prop Samson Lee was shown a yellow card and a series of controversial incidents including a biting allegation, France finally got over the line for the second time.
"I'm an old man but I had never seen anything like this," said France coach Guy Noves, who responded angrily to a reporter suggesting Wales winger George North had been bitten in stoppage time.
Noves bit his hand and said: "Look, there's a bite mark, here."
There was also confusion surrounding late replacements with France prop Uini Atonio being substituted by Rabah Slimani.
"I was told he was injured so I took my responsibilities," said Noves when asked if the substitution was tactical.
Lopez scored two penalties and two conversions, making sure Les Bleus will finish the championship in second or third place and leaving Wales in fifth ahead of the Ireland v England clash.
Noves's team started well, going ahead when Remi Lamerat collected a subtle chip over the top from Lopez and dived over the line. The flyhalf slotting home the conversion and added a routine penalty as France's domination continued.
Wales, however, responded with two penalties after Virimi Vakatawa was shown a yellow card for a deliberate knock on.
Wales reduced the arrears again when Halfpenny slotted his third kick as France were repeatedly penalised by referee Waynes Barnes.
The hosts struggled to retain possession in a scrappy start to the second half and Halfpenny's perfect afternoon continued as he booted a 45-metre penalty to put the visitors in front for the first time.
Sebastien Vahaamahina grabbed Tipuric's arm in the air in a lineout, handing Halfpenny another 45-metre opportunity which the fullback slotted between the posts to give Wales a five-point lead.
The teams traded penalties and France, needing a try, opted for the scrum when they were awarded a last-minute penalty.
After 20 minutes of mayhem, including numerous replacements and desperate Welsh defence, Chouly finally claimed the winning try.
Photo: PHOTOSPORT Damien Chouly of France wins the ball at a lineout.