A brilliant 87th minute free-kick from Dani Alves secured the win for the South Americans, who now advance to play the USA in Sunday’s Final. South Africa will meet Spain once again in the third-place play-off on the same day.
Sporting their snazzy new green kit, Bafana were struggling to find their passing range early on and it was Ramires who had the first effort on goal, shooting from the edge of the area but straight at Itumeleng Khune.
It was followed soon afterwards by a blistering shot from 30-yards by Siboniso Gaxa that missed the far post and, in fairness, Brazilian goalkeeper Julio Cesar appeared to have it covered in any case.
Bafana skipper Aaron Mokoena should have given the home side the lead after 21 minutes when he rose unmarked to meet Teko Modise’s long free-kick, but he couldn’t keep his header down and it powered over the bar with the Brazilian defence all at sea.
It was all Bafana at this stage but, for all their possession, poor passing and too much time on the ball meant they failed to trouble Julio Cesar.
Siphiwe Tshabalala, who had looked lively early on, finally tested the palms of the Brazilian goalkeeper with a well-struck free-kick from 35-yards, but in truth it was a save you would expect the stopper to make.
Modise then wasted a great chance for Bafana on the counter as they found themselves in a three-on-three situation, but he took the worst option ... to shoot from 35-yards and the ball went hopelessly wide, much to the disgust of Bernard Parker.
Andre Santos had an effort from 30-yards with his left-foot that was comfortably saved by Khune, while a mazy run from Kaka saw him side-foot a shot from the edge of the area that flew just wide of the post with the goalkeeper beaten.
Khune again had to be alert after Kaka steamed down the right flank, took on Matthew Booth and fired a low shot towards the bottom corner, while at the other end Julio Cesar got a touch to a drive from Pienaar, but the decision was a goal-kick.
Tsepo Masilela fouled Andre Santos to provide a free-kick chance for the Brazilian left-back, but Pienaar showed the kind of excellent commitment he had displayed all night to rush to block the effort.
Robinho had the first effort of the second half, a shot from 30-yards that was never troubling Khune, while Kaka headed over after neat build-up play on the right.
Modise forced Julio Cesar into a fine save after a deflected shot was just squeezing in the post, while at the other end, Khune was forced into some work by the quiet Luis Fabiano, and then Mokoena’s poor clearance allowed Robinho to try an acrobatic effort that went wide.
Great persistence from Masilela and Tshabalala down the left saw the latter cross for Parker, who rose unmarked, but could not get his head to the ball, while Mokoena did brilliantly to get across and block a shot from Robinho.
But the second half was proving a much tighter affair than the first with both side’s struggling for clear-cut openings.
Mokoena brought down Ramires with a needless foul on the edge of the area with just four minutes to play, and the home hearts were broken as substitute Alves stroked home the free-kick past an unsighted Khune.
The Bafana goalkeeper then made a tremendous save to deny Fabiano when the Brazilian looked certain to score.