Wales coach Warren Gatland said he thought the better team lost after his side advanced into the World Cup semi-finals with a breathless 20-19 victory over France in Oita. Les Bleus were leading 19-10 when lock Sebastien Vahaamahina was sent off for an elbow in the 48th minute, and it proved to be a pivotal moment. Wales subsequently secured the win with substitute Ross Moriarty's 74th-minute try, converted by Dan Biggar, and face South Africa next weekend for a place in the final. When asked about his emotions, Gatland said: "We're relieved. I think the better team lost today. The thing about our boys is they don't give up, they keep trying until the end. We kept working away. "France came out of the blocks well. At half-time we just said we've got to score next, we did that and obviously the red card was the turning point. It was pretty special. "They did go hard, lots of big men, big runners and they got some go-forwards. Tactically, I thought they were really smart today. We just hung in there and showed some real character. I'm proud of the boys because I think lesser teams would have capitulated but we didn't do that. "We'll just go back, recover today and travel to Tokyo tomorrow. I don't think we've got too many injuries. We'll probably have a quiet night tonight! "So, not the prettiest in the world, but some great character shown. Losing becomes a habit but so does winning as well, so we are in that sort of winning habit at the moment." Wales captain Alun Wyn Jones also highlighted his side's character. He said: "I think we were slow out the blocks. We probably continued in a similar vein to how we started against Fiji, which is slightly disappointing. "But the character we showed to come through - obviously there was an advantage in the second half after the card, but we kept plugging away and came out on the right side of the scoreboard. "We're pleased. There is plenty for us to work on, but ultimately we are pleased with the result." A moment of madness certainly cost France when Vahaamahina was sent off for elbowing Aaron Wainwright nine minutes into the second half with his side leading by nine. 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 the hard work the three-time finalists had put in. Defeat also brought the curtain down on France coach Jacques Brunel's two-year spell in charge before he is replaced by former captain Fabien Galthie. 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 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. 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 monster 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. Looking ahead to the semi-finals, Jones added: "The days and weeks feel a little bit longer because of the magnitude of the occasion but we've been to some dark places in preparation for this."