United States were among four teams to progress to the quarter-finals of the World Rugby Sevens with unbeaten records in Singapore.
South Africa trailed 19-0 after a first half that was completely dominated by Fiji but turned the match around after halftime, matching Fiji's three tries and snatching the win with the last-gasp goal.
The series leaders were one of three teams that began the weekend with the chance to secure qualification to the Tokyo 2020 Olympic Games.
"Our expectation here in Singapore is to try and build on our performance in Hong Kong", England captain Tom Mitchell said. Fiji also lost to Scotland and only just scraped through to the final.
South Africa sits in fourth place in the World Series standings with 121 points while Fiji is second with 142 points.
Meanwhile, Fiji takes on New Zealand in the third quarter-final match at 4.14pm. Hirayama kicked four conversions. But the French pulled ahead on second-half tries by Remi Siega and Tavite Veredamu. Tries by Tim Mikkelson and Akuila Rokolisoa in the final two minutes of the match swung the tie in the All Blacks Sevens' favour.
Napolioni Balaca spun through another weak tackle to score in the fifth minute and Vilimoni Botitu capped an outstanding half for Fiji with a try from a five-meter scrum just before the break.
Most of the spectators would have thought that Fiji had the trophy in the bag, and avenged Saturday's opening stage defeat by South Africa.
But the Blitzboks roared back in the second spell, with Kurt-Lee Arendse, Angelo Davids and Ryan Oosthuizen dotting down to cut the deficit to two points with two minutes remaining, while Aminiasi Tuimaba was also shown a yellow card for a unsafe tackle.
Playing without the injured Jerry Tuwai, the Fijians struggled as they again went down 17-7 to South Africa in their final pool play.
Selvyn Davids then slotted a penalty right in front of the posts to give the Blitzboks a 20-19 lead with seconds left on the clock.