Oita, Japan: Substitute Ross Moriarty snatched a late winner as Wales eliminated 14-man France in a breathless World Cup quarter-final to exorcise the ghosts of their 2011 heartbreak on Sunday.
A moment of madness cost France dearly in Oita after lock Sebastien Vahaamahina was sent off for elbowing Aaron Wainwright nine minutes into the second half with his side leading by nine points.
Wales, paced by 10 points from fly-half Dan Biggar's perfect boot, face either South Africa or hosts Japan in the semi-finals next weekend after surviving a scare against the swashbuckling French, who led until the 74th minute.
Still haunted by the memory of a stinging 9-8 semi-final loss to France eight years ago, the Six Nations champions looked decidedly uncomfortable until Vahaamahina's rush of blood undid all the hard work the three-time finalists had put in.
Defeat also brought the curtain down on France coach Jacques Brunel's two-year spell in charge before he is replaced by former captain Fabien Galthie.
"I think the better team lost today, but that red card was obviously significant," said Wales coach Warren Gatland, who is also due set to step down after the World Cup.
"But credit to the players -- I'm really proud of the fact they never give up and kept fighting and found a way to win. Other teams would have probably capitulated."
Vahaamahina had stunned the Welsh by bundling over from a lineout after just five minutes before France scored one of the tries of the tournament.
Roared on by chants of "Allez, Les Bleus!" flanker Charles Ollivon stormed through to complete a sweeping move involving Virimi Vakatawa, Romain Ntamack and scrum-half Antoine Dupont.
Back came Wales in an electrifying opening 12 minutes as flanker Wainwright pounced on a loose ruck on halfway to race clear for his first Test try.
Biggar slotted a penalty to bring the Six Nations champions to within two points.
But when a high tackle from substitute Ross Moriarty on Gael Fickou resulted in a yellow card, France made Wales pay as Damian Penaud released Vakatawa to grab France's third try on the half-hour mark.
French playmaker Ntamack struck the post with a penalty just before the break but the pendulum swung towards Wales after Vahaamahina's rush of blood.
Caught on camera recklessly swinging his elbow flush into Wainwright's face, it was only ever going to result in a red card.
His dismissal came as an ironic twist as then Welsh captain Sam Warburton received an early red card for a dangerous tip tackle on Vincent Clerc in that 2011 semi-final in Auckland.
Wales, who had won seven of their last eight games against France, were still made to work for it in a nail-biting finish.
But just when France looked like holding out for a famous victory, Moriarty popped up after a monster Welsh scrum.
Making up for his earlier indiscretion, the replacement forward bulldozed over six minutes from time before Biggar kicked the conversion that broke French hearts.
"I don't dispute the red card -- he made contact with the player's face," shrugged Brunel, who claimed there was a knock-on in the build-up to Moriarty's decisive try.
"But there were other decisions I didn't agree with -- I'd like to see those images again. But what happened today will serve as a good lesson for us in the future."