A moment of madness cost France in Oita after lock Sebastien Vahaamahina was sent off for elbowing Aaron Wainwright nine minutes after half-time 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.
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 of France’s hard work.
Defeat also brought the curtain down on France coach Jacques Brunel’s two-year spell in charge of the three-time World Cup finalists.
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 monstrous 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.