The Barcelona full-back replaced Andre Santos with eight minutes remaining and soon made the difference.
Two minutes from time, Alves' fiercely struck free-kick from the edge of the area sailed into the far top corner to break South Africa's resistance.
Brazil, who won the tournament's previous edition in 2005, face the United States in the final on Sunday while South Africa meet European champions Spain in the third-place play off.
The Bafana Bafana looked capable of causing another major upset after the US eliminated Spain with a 2-0 victory on Wednesday.
They had the upper hand in the first half and could have grabbed the lead more than once.
Brazil struggled against a tight South African defense, just like Spain who failed to break down the US backline.
Skipper Aaron Mokoena headed over the bar with the goal at his mercy after being found by a right-wing cross midway through the first period.
Brazil's only chance before the break fell to inspirational playmaker Kaka, who skillfully evaded Mokoena before curling a brilliant shot that narrowly missed the target.
South Africa midfielder Steven Pienaar, who was voted man of the match, came close to stunning Brazil in the 43rd minute but his powerful drive went just wide of the post.
The second half was a dull affair as both sides had a cautious approach.
Alves' remarkable free-kick settled the tie into Brazil's favor as the five-time world champions avoided suffering a shocking exit.