Sergio Rodriguez converted two free throws with 5.4 seconds left as Spain salvaged an 89-88 victory over heartbroken Australia for Olympic basketball bronze on Sunday.
Rodriguez drew a foul from Patty Mills and stayed cool on his only free throws of the match for victory.
Australia had one more chance but fumbled the ball away for a 15th turnover as they missed Olympic silverware yet again in fourth place, for the fourth time in the last seven editions.
Pau Gasol paced Spain with 31 points while Mills led the way for the Boomers with 30.
Spain opened up a 40-28 cushion in the second quarter but the Australians went on a 10-0 run to cut the deficit to two at halftime, and guard Matthew Dellavedova put them ahead 43-42 for the first time since an opening 2-0.
The game remained tight from then on, and Australia thought they had won it when centre Aron Baynes laid in over Gasol for 87-86 with 10 seconds left.
But Spain came back to get a third straight medal, following silvers in 2008 and 2012.
In the final later Sunday, the US seek a 17th basketball gold over Serbia in what is also the 306th and final medal event of the Rio games.