You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
France were leading 19-10 when Vahaamahina had a moment of madness - elbowing Aaron Wainwright in a maul - and though they defended superbly after that, replacement number eight Moriarty, who had been yellow-carded himself earlier, won it six minutes from time when he grabbed a loose ball and forced his way over the line.
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 to reach the last four for the third time, having lost to New Zealand in 1987 and France in 2011. They will face either South Africa or Japan, who meet later on Sunday.
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.
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 right 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.
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.