South Sudan and Japan both qualified for the Paris Olympics at the Basketball World Cup on Saturday as the tournament's highest-placed finishers from Africa and Asia.
World Cup debutants South Sudan, who played their first official international game only six years ago, beat Angola 101-78 in Manila to claim their third win of the competition.
Nearest challengers Egypt then lost 88-86 to New Zealand to send South Sudan to Paris, completing the world number 62-ranked team's fairytale rise on the world stage.
The country has lurched from one crisis to another since winning independence in 2011 but the team's World Cup performances have captured the public's imagination, with crowds gathering to watch on giant screens in the capital Juba.
An emotional head coach Royal Ivey said they had brought "unity, camaraderie, love and friendship" to the country.
"This team is a beam of light," he said.
"This country has only been independent for 12 years. To do this is incredible."
South Sudan have won plaudits for their dynamic play and positive attitude on and off the court at the World Cup being held in the Philippines, Japan and Indonesia.
They pulled off a historic win when they beat basketball-obsessed China in their second game, before downing the Philippines in the classification stage.
South Sudan captain Kuany Ngor Kuany said he was proud to "create history" by representing his country.
"We've had a lot of athletes representing different countries under different flags," said Kuany, who was born in South Sudan but moved to Australia as a nine-year-old.
"For us to be able to do it for the first time as a country really means a lot and that's why we were fighting so hard to be able to get that opportunity."
- Japan clinch spot -
Japan claimed their place at the Paris Games with a nervy 80-71 win over Cape Verde in Okinawa.
Japan had not qualified for the Olympic basketball tournament except as hosts for 48 years, but their third win of the World Cup put them out of reach of their nearest Asian challengers.
They came from behind late to beat both Finland and Venezuela and head coach Tom Hovasse said they had "gained the respect of our opponents".
"I think we showed the world what we can do, and now we're on everybody's radar, we're on everybody's map," said the American, who led Japan's women's team to the Olympic silver medal in Tokyo two years ago.
"Gaining respect is a big step, winning games at this level is a huge step, so I'm really proud of what we did."
Japan took control against Cape Verde but suffered a late meltdown that almost cost them the game.
They conceded the first 13 points of the fourth quarter before they regained their composure to close out the win.
Hovasse said the fourth quarter was "hectic and could have been disastrous" but trusted his players to come through in the end.
Japan's win meant China were eliminated from Olympic qualifying contention before their game against the Philippines had even ended.
In the event, they lost 96-75 to the co-hosts for their fourth defeat of the tournament.
"Once you're tired, once the difficulties start, you have to use your head -- our head was not used in the proper way tonight in the second half," said China head coach Aleksandar Djordjevic.
The highest-placed World Cup finishers from each of Asia, Africa and Oceania all qualify for Paris, along with the top two teams from both Europe and the Americas.
Australia have already claimed the Oceania berth, while France qualify automatically as hosts.
Four further spots at the 12-team Olympic competition will be up for grabs at next year's qualifying tournament.