Wales staged a stunning fightback victory to win a gripping World Cup quarter-final in Oita after France pressed the self-destruct button .
The Six Nations champions' 20-19 victory was secured by Ross Moriarty's 74th-minute try that Dan Biggar converted.
Wales will now play South Africa in next Sunday's semi-final after they beat Japan.
There was an agonising wait while the officials checked for a possible Wales knock-on in build-up play, but the try was awarded.
A Wales win looked unlikely for long periods as an often flamboyant and brilliant French team dominated.
But the game changed course after Les Bleus lock Sebastien Vahaamahina was sent off in the 48th minute for elbowing Wales flanker Aaron Wainwright in the face.
Wales head coach Warren Gatland steps down after the tournament following a 12-year reign highlighted by three Six Nations Grand Slams.
And Wales' World Cup adventure will now continue for at least another week, with Japan or South Africa their semi-final opponents.
Wales were rattled by an aggressive French start as their big ball-carriers made headway.
It was all hands to the pump for Wales' defenders in a frenetic start, where the ball didn't go out of play for the first two and a half minutes.
France went ahead after five minutes when lock Sebastien Vahaamahina powered over for a try from close range.
And before Wales could recover from that setback, they fell further behind after a brilliant France move from inside their own half saw Dupont deliver a scoring pass to flanker Charles Ollivon.
Fly-half Roman Ntamack converted Ollivon's score, and France were rampant, leading 12-0.
Wales had to reply quickly following such an unsettling opening and they delivered courtesy of a 12th-minute try for flanker Aaron Wainwright.
The Dragons forward, who had never previously scored for his country, gathered a loose ball and then galloped clear from 30 metres out to touch down, with Biggar's conversion making it 12-7.
It was a strong response, and then Biggar kicked a penalty to leave Wales just two points adrift after 20 minutes.
Wales were well and truly back in the contest, and they began to shade the territorial battle, despite Penaud sparking another dangerous France attack.
The Six Nations champions then suffered an injury blow, though, when flanker Josh Navidi went off. He was replaced by Ross Moriarty.
But Moriarty had not been on the pitch for two minutes when referee Jaco Peyper yellow-carded him for a high tackle on France centre Gael Fickou.
Moriarty's exit left Wales at sixes and sevens, and France punished them in ruthless fashion when centre Virimi Vakatawa crossed for their third try.
Ntamack converted to make it 19-10, before hitting the post with a penalty that would have restored Les Bleus' early 12-point advantage.
Fourteen-man Wales were hanging on and they had to reach half-time without conceding again, which they just about accomplished, but they still had a mountain to climb.
Ntamack went off at half-time and was replaced by Camille Lopez, whose first contribution was to send a drop-goal attempt narrowly wide.
But Les Bleus still had momentum, and the Welsh defence continued to be asked many questions, before Vahaamahina was sent off for elbowing Wainwright in the face.
His reckless act left Peyper with no choice and France were down to 14 men for the final 32 minutes.
A Biggar penalty cut the gap to six points as Wales looked to make their numerical advantage count.
It was a case of keeping their patience, but France were not visibly rattled by losing Vahaamahina, despite mounting Wales pressure.
And with 15 minutes left, Les Bleus led 19-13.
But then the fine, tight and gripping match came to its thrilling climax.
Wales were pouring forward in search of the converted try that would sweep them ahead and it came in the 74th minute through Moriarty.
Vahaamahina's absence had left France underpowered at the scrum and when they were shoved backwards five metres from their own whitewash the ball came loose, a rip forcing it to Justin Tipuric who charged forward.
He did not quite have the power to cross but Moriarty did as he grabbed the ball and touched down with Biggar kicking the conversion that sealed a 20-19 win.
More to follow.