Xabi Alonso's free-kick in extra-time enabled Spain to see off the plucky challenge of South Africa and clinch third place in the Confederations Cup with a 3-2 win.
European champions Spain, whose 35-match unbeaten run came to a shock end against the United States in the semi-finals, were lethargic for much of the encounter and appeared to be heading for another defeat when Katlego Mphela put Bafana Bafana ahead after 73 minutes.
However, two goals in the final three minutes from substitute Daniel Guiza turned the match around only for Mphela to send the game into extra-time with a blistering free-kick, but Spain sealed it when Liverpool midfielder Alonso curled a 107th-minute free-kick.
Both sides had chances to win it in the first period of extra time, Joan Capdevila's cross clipping the bar while at the other end Iker Casillas saved well from Katlego Mphela - denying the striker a hat-trick when he had had burst through - and Bernard Parker.
But it was Alonso who had the final say two minutes into the second period with a clever free-kick which eluded everyone and ended up in the bottom right-hand corner.
Copyright (c) PA Sport 2009, All Rights Reserved.
Do YOU want to write for GiveMeSport? Get started today by signing-up and submitting an article HERE: https://www.givemesport.com/writeforgms