France were leading 19-10 when Vahaamahina, in a moment of madness, inexplicably elbowed Aaron Wainwright's in the face and, though the French defended superbly after that, replacement number eight Moriarty, yellow-carded himself earlier, won it six minutes from time by grabbing a loose ball and forcing his way over.
Eight years ago an early red card for Wales captain Sam Warburton played a key role as France triumphed 9-8 in their World Cup semi-final in Auckland.
This time it was the Welsh who benefited and edged a one-point game to reach the last four for the third time, having lost to New Zealand in 1987 - when Moriarty's father Paul scored a try in the third-place playoff win over Australia - and France in 2011.
World Cup
Relentless South Africa beat England to win Rugby World Cup
01/11/2019 AT 22:02
"I think the better team lost today," said Wales coach Warren Gatland. "That red card was significant. Our boys don't give up, though. It was a tough physical game and we kept plugging away.
"Tactically, France were really smart in the way they played today. I'm proud of the boys because other teams may have capitulated but we didn't and we are here for another couple of weeks."
The French will be furious that they allowed themselves to be forced onto the defensive, having played superbly for most of the opening 50 minutes.
The perennial question of 'which France will turn up?' was answered emphatically as they roared into a 12-0 lead after eight minutes, playing with pace, dynamism and total commitment.
Vahaamahina bundled over for the first score before Damian Penaud set up the second by beating Liam Williams in an aerial duel – which very few people can manage – to set his backline moving and eventually sent flanker Charles Ollivon over.
Wales had barely swung a punch but got on the scoreboard when Wainwright scooped up a dropped ball to gallop between the posts for his first international try.
Wales, who suffered a blow pre-match when star centre Jonathan Davies was ruled out through injury, then lost another key man in number eight Josh Navidi.
The first contribution of his replacement Moriarty was a high tackle that sent him straight back off again for 10 minutes in the sin-bin.
France duly took advantage with their third try as Penaud managed to unload a diving pass out of the tackle to Virimi Vakatawa, and the unstoppable centre proved just that.
The halftime score of 19-10 was extremely kind to Wales and every player in both camps would have been well aware that earlier this year France led 16-0 at halftime in Paris but lost 24-19 as Wales completed the biggest comeback in Six Nations history.
Something similar then began to look likely when Vahaamahina turned from hero to villain as he was shown a red card after ludicrously smashing his elbow into the face of Wainwright in a maul on the Welsh line.
France responded by buckling down and showing real aggression in defence, giving up just one Biggar penalty in the next 25 minutes.
But just as it looked as if they might hold out for a memorable victory, replacement scrum half Tomos Williams stripped the ball from French hands after a five-metre scrum and Moriarty, villain turned hero, more than made up for his earlier yellow by grabbing it and diving over.
After a long TMO check, the try was confirmed. Biggar converted and Wales controlled the remaining minutes to record their eighth win in the teams' last nine meetings - and by far the most important.
World Cup
Brilliant England end New Zealand run to reach World Cup final
26/10/2019 AT 10:15
World Cup
Hansen knocks down 'clever Eddie' spy psychology
24/10/2019 AT 06:49