Fiji will face Japan and Great Britain will tackle South Africa in the semi-finals of the Men's Sevens at the Rio Olympics.
Great Britain needed extra time to beat Argentina but South Africa brushed Australia aside in the last quarter-final.
Japan scored late on to edge a desperately tense clash with France moments after World Champions New Zealand were the first major casualty of the Men's Sevens quarter-finals, losing to the top seeds Fiji.
Fiji 12-7 New Zealand
Japan 12-7 France
Great Britain 5-0 Argentina
South Africa 22-5 Australia
SOUTH AFRICA 22-5 AUSTRALIA
South Africa made amends for losing to Australia during the pool stages, recording a convincing victory to keep their hopes of a gold medal alive.
Rosco Specman opened the scoring for the Blitzboks after receiving a inside pass from his captain Kyle Brown for a 5-0 lead.
Speedster Seabelo Senatla extended the lead to 10-0 after finishing off out wide, but Australia hit back quickly with a try of their own through Tom Cusack, reducing the deficit to only five points.
Juan de Jongh was denied a try after some desperate defending by the Aussies which forced his foot into touch before he lost the ball on the line. A poor clearance kick by the Australians saw Brown give his side a commanding 17-5 lead with less than three minutes to go.
Senatla added his second late in the second half to secure South Africa’s semi-final against Great Britain on Thursday.
GREAT BRITAIN 5-0 ARGENTINA
The game finished 0-0 after normal time of a tense, closely fought encounter. In a closely contested game, both teams had chances to win but in the end Britain sneaked through by the skin of their teeth.
Argentina missed a penalty drop kick which would have given them a vital lead. Juan Imhoff was yellow carded with 40 seconds left on the clock for a dangerous tackle, but Argentina managed not to concede any points during his absence.
James Davies suffered a similar fate for Great Britain, but again the opposition team failed to capataliseand the game ended 0-0.
An extra five minutes of sudden death followed and Britain got the first chance to win the game with a penalty. They came agonisingly close, but Tom Mitchell's effort hit the upright to leave the game in the balance.
Not long after Dan Bibby scored the winning try after throwing a dummy pass which gave him the gap to dive over for the five-pointer.
JAPAN 12-7 FRANCE
France took a 7-0 half-time lead thanks to a try by Damian Cler. Lote Tuqiri got one back for Japan, but the conversion was miss which gave France a tiny lead for most of the half. They seemed to have this one in the bag, but a late onslaught by Japan inside the French 22 saw them score the winning try with less than 20 seconds to go after Teruya Goto picked the ball up from a ruck and barged over for the match-winning try.
FIJI 12-7 NEW ZEALAND
Fiji booked their place in the semi-finals thanks to a hard-fought win over their old rivals. Fiji will now face Japan in the semi-finals.
The defeat brings to an end a miserable and underwhelming tournament for the New Zealanders, who suffered a shock loss to Japan in their opening pool match before also losing to Great Britain.
Fiji scored first through a great team try, showcasing their skills in wet weather with breathtaking offloads to take a 5-0 lead. The Kiwis were reduced to six men when Rieko Ioane was sin-binned for a dangerous tackle.
Fiji failed to capatalise on their numerical advantage. Instead, New Zealand took a slim 7-5 lead into half-time after some individual skill by Gillies Kaka, who chipped and chased his own kick before falling on the ball behind the tryline.
Both teams struggled in a sloppy second half, but Fiji enjoyed more possession and scored what turned out to be the winning try through Jerry Tuwai. New Zealand struggled to get their hands on the ball and when they did they couldn't do much with it.
USA 24-12 Brazil
Spain 14-12 Kenya
Pool A – Argentina, Brazil, Fiji, USA
Argentina 31-0 Brazil
Fiji 24-19 USA
Fiji were made to work hard in their last pool match against the USA but eventually booked their place thanks to a 24-19 victory.
The USA took an early lead thanks to a Danny Barrett try but Fiji were soon level when their captain Osea Kolinisau crossed the whitewash and they went into the break holding a 12-7 lead after Vatemo Ravouvou scored their second try.
The Eagles were fastest out of the blocks when Perry Baker dotted down early in the second half but tries from Viliame Mata and Semi Kunatani gave Fiji a 24-14 lead.
Nate Ebner scored a late try for the USA but the conversion was off target which meant Fiji secured a 24-19 victory.
Earlier, Argentina secured their spot in the quarter-finals when they beat Brazil 31-0.
Pool B – Australia, France, South Africa, Spain
France 26-5 Spain
South Africa 5-12 Australia
South Africa lost their final pool match, against Australia, but still qualified for the medal quarter-finals along with France.
The Blitzbokke's 12-5 defeat to Australia and France's 26-5 victory over Spain, in the day's opening match, means that South Africa, France and Australia all finished on seven points in the group with South Africa in first place, thanks to a superior points difference and France next best.
Jesse Parahi scored the first points of the competition against the Blitzbokke, when he crossed for a try in the first half, and another five-pointer from Tom Cusack meant Australia led 12-0 at half-time. Seabelo Senatla scored a try for South Africa, early in the second half, but that was their only points as Australia held on for victory.
Earlier, a brace of tries by Virimi Vakatawa helped France to an easy win over Spain.
Pool C – Great Britain, Japan, Kenya, New Zealand
Kenya 7-31 Japan
New Zealand 19-21 Great Britain
Great Britain claimed a 21-19 win over New Zealand to top the pool with three wins out of three while Japan finished second after beating Kenya 31-7.
New Zealand did most of the early attacking against Great Britain but their opponents soaked up the early pressure and Mark Bennett crossed for the opening try midway through the first half. Shortly before half-time, James Davis and Dan Norton also crossed the whitewash which meant Great Britain led 21-0 at the break.
New Zealand struck back with tries from Rieko Ioane, Regan Ware and Sam Baker in the second half but Gilles Kaka failed to convert Ioane's five-pointer which meant his side suffered the two-point loss.
Japan booked their place in the play-offs thanks to an easy win over their African opposition with Lomano Lemeki leading the way with two tries.