The South Africans led by 5-0 at the break, but Japan scored three unanswered tries in the second half to clinch 11th spot at the tournament.
The match started tentatively by both sides as the heavy schedule from the last few days were taking its toll, while good defence kept the attack at bay.
However, after the buzzer had sounded, Marlize de Bruin finished in the corner for her first World Series try after South Africa had some good possession in the Japanese 22 to see the host nation take a 5-0 lead into the break.
Japan levelled the scores exploiting some missed tackles with a try in the second minute of the second half by Michiyo Suda, and then took the lead with a second try, by Sakura Mizutani with three minutes to go.
The South Africans then failed to get their hands on the ball and Japan sealed the win when Marin Kajiki scored at the death.
Scorers:
Springbok Women's Sevens 5 (5) - Try: Marlize de Bruin.
Japan 15 (0) - Tries: Michiyo Suda, Sakura Mizutani, Marin Kajiki.
A high penalty count and unnecessary errors in the second half cost the Springbok Women's Sevens team in their ninth-place semi-final as they were edged 17-12 by Spain on Sunday morning.
The seventh-seeds from Europe scored first as Olivia Fresneda went over in the left corner in the third minute after they turned over possession on the ground inside the SA 22.
But the Bok Women hit back two minutes later when Veroeshka Grain finished a good play when they managed to hold on to possession, with the move involving a few strong runs from Jakkie Cilliers and a great offload by Marlize de Bruin.
Nadine Roos converted to put SA in the lead by 7-5, but it was short-lived as Spain scored from the restart, Amaia Erbina racing away for a converted try to put the women in red back in the lead, 12-7.
But Roos had the final say in the first half as she snapped up a loose ball and ran all of 70m to score a solo-try. The conversion went wide and it was 12-12 at the break.
Spain started the second half in command, with a bunch of early penalties conceded not helping the SA cause, and after some attacking pressure Ingrid Algar's try restored their lead at 17-12.
South Africa's discipline kept on being an issue and with just over two minutes to go, Kemiketso Baloyi was yellow carded, although they continued to fight on defence, with a great tackle from Felicia Jacobs dislodging the ball over the tryline.
However, the Bok Women could not get their hands on the ball or out of their own half, and they ran out of time in the end.
Scorers:
Springbok Women's Sevens 12 (12) - Tries: Veroeshka Grain, Nadine Roos. Conversion: Roos.
Spain 17 (12) - Tries: Olivia Fresneda, Amaia Erbina, Ingrid Algar. Conversion: Claudia Peña Hidalgo.