France booked their place in the Rugby World Cup quarter-finals but made hard work of beating Tonga 23-21 in Kumamoto.
Jacques Brunel's men looked set to triumph with ease on Sunday when they moved into a 17-0 lead, thanks largely to the impressive Alivereti Raka scoring one try and laying on another for Virimi Vakatawa.
However, Tonga - who famously stunned France with a 19-14 win in the 2011 pool stage - came roaring back, cutting their deficit to three points through converted scores from Sonatane Takulua and Malietoa Hingano.
Two Romain Ntamack penalties gave France breathing space, but they ended up hanging on for victory after a 78th-minute try from Tonga's Zane Kapeli. Les Bleus will know they must improve significantly in order to beat England on Saturday in what is now a shootout for first place in the pool.
Tonga were ultimately punished for a sloppy start, which saw them fall 10-0 down inside six minutes.
An early Ntamack penalty was followed by Vakatawa's score, the centre left with an easy finish after Raka's fine break and pass.
Raka got on the scoresheet himself after 31 minutes, collecting his own chip to dot down after Baptiste Serin's quick tap-and-go had caught Tonga napping.
Yet the underdogs were given hope before the break when scrum-half Takulua burrowed over for a score he also converted.
Charles Ollivon galloped over for France early in the second half, but his try was chalked off for a forward pass from Sebastien Vahaamahina and Tonga immediately capitalised on the let-off, Hingano crossing after Cooper Vuna's kick had bounced awkwardly to deceive Maxime Medard.
A pair of three-pointers from Ntamack eased French nerves and ultimately proved vital as Kapeli latched on to a high kick to earn Tonga a deserved bonus point.