French lock Sebastien Vahaamahina was sent off after smashing his elbow into the face of Wales flanker Aaron Wainwright, the Player of the Match, on 48 minutes in a mindless act that cost his side the game.
Just like Sam Warburton's red card in the semi-final between these sides in Auckland in 2011, the dismissal - with France leading 19-10 - finally proved to be game-changing at Oita Stadium.
Moriarty, who was yellow-carded in the first-half, picked up from on the line to score a try that was awarded after review, with France claiming a knock-on. Biggar's conversion put Wales ahead for the first time in the match and completed the comeback. Early in the first half Wales had been 12-0 down.
Their head coach, Warren Gatland - whose 12-year reign looked to be ending in hugely disappointing fashion - will know how close Wales came close to going out. Despite the score it was no statement of intent from Wales side after the emphatic victories by England and New Zealand in Saturday's quarter-finals.
Wales suffered a blow just over an hour before kick-off when centre Jonathan Davies was ruled out after aggravating the knee injury he suffered in the win over Fiji. Owen Watkin was drafted in from the bench.
And how badly Davies's calmness and experience was missed in a nightmare opening 40 minutes for Wales as centre Virimi Vakatawa ran amok in the midfield.
France were helped by some poor defensive kicking, handling errors and a general sloppiness about Wales's play as they struck for two tries inside eight minutes.
Vahaamahina powered over within five minutes as France drove close to the line from a lineout after Dan Biggar's poor clearance under pressure. No wonder under-pressure France coach Jacques Brunel punched the air.
Three minutes later Vakatawa made a break just inside the Welsh half and slick handling sent flanker Charles Ollivon racing in at the posts.
Wales badly needed a reply and got it on 12 minutes when Guilhem Guirado spilt the ball in a crunching tackle and flanker Wainwright picked up to sprint home from 48 metres, pictured above. What a time to score your first test try.
Biggar reduced the deficit to just one point with a penalty but just as Wales looked to be getting on top - and playing the controlled game they wanted from the start - they suffered another injury blow as No 8 Josh Navidi limped off. Replacement Moriarty had barely been on the pitch when he was yellow-carded for a high tackle on centre Gael Fickou.
France immediately took advantage as Vakatawa used the extra numbers to cut inside for the comfortable try. Fy-half Romain Ntamack's conversion took the advantage back up to nine points.
Wales were desperately hanging on for the half-time whistle and would have been further behind but for a penalty by Ntamack hitting a post. Ntamack was replaced at the break by Camille Lopez, having taken a big hit.
Wales had overturned a 16-0 deficit in Paris in February to triumph 24-19 and claim a seventh win in eight attempts thanks to mistakes by France, including a wild long pass by Vahaamahina which George North picked up to score a try.
This time Vahaamahina was guilty of mindless foul play as he hit out with his elbow into the face of Wainwright in a maul, having already grabbed him around the neck.
South African referee Jaco Peyper had no option but to make the Clermont forward the first French player to be sent off in the World Cup.
Biggar kicked a penalty to bring Wales within one converted try of taking the lead and they would have got it but for wing Yoann Huget superbly snaffling North's attempted looped pass.
But just as time looked to be ticking away, Wales won possession from a scrum close to the line and Moriarty atoned for his earlier yellow card with the winning try.
Wales - Tries: Aaron Wainwright, Ross Moriarty. Conversions: Dan Biggar (2). Penalty goals: Biggar (2).
France - Tries: Sebastien Vahaamahina, Charles Ollivon, Virimi Vakatawa. Conversions: Romain Ntamack (2).