Wales took advantage of the second-half sending-off of France lock Sebastien Vahaamahina to rally for a 20-19 win and a place in the Rugby World Cup semi-finals.
Trailing 12-0 after eight minutes, the Welsh were also 19-10 behind and being dominated by France when Vahaamahina elbowed Wales flanker Aaron Wainwright in the face in a maul and was shown a red card in the 49th minute.
Dan Biggar's penalty goal reduced the deficit to six points before Wales pushed back France in a 74th-minute scrum near the French line and the ball popped into the air. Justin Tipuric gathered it, was tackled on the line, only for Ross Moriarty to collect and barge over for a try converted by Biggar.
France looked on course for a seventh appearance in the semifinals after scoring three tries in the first half through Vahaamahina, Charles Ollivon and Virimi Vakatawa.
Wales will play South Africa or host nation Japan in the semi-finals.