Johannesburg, June 26 (DPA) A late free-kick from substitute Daniel Alves sent five-time world champions Brazil into the final of the Confederations Cup with a 1-0 win over hosts South Africa in Johannesburg Thursday.

Brazil now take on the US in the final in Johannesburg Sunday while South Africa meet European champions Brazil in the match for third place in Rustenburg the same day.

Brazil beat US 3-0 in Pretoria in a group game June 18 on their way to the semi-final.

Barcelona defender Alves came off the bench in the 82nd minute to strike an unstoppable free-kick six minutes later past the defensive wall from the edge of the penalty area.

Alves got his chance when Ramires was upended on the edge of the box by central defender Aaron Mokoena. His shot went straight past the left of the wall and just inside the post, with keeper Itumeleng Khune powerless despite diving full stretch.

South Africa had matched the title-holders for much of the game and had several shots on or just wide of the target.

Brazil’s best chance was a Kaka shot curled just wide of the post in the first half.

Steven Pienaar – adjudged man of the match – came close just before the break with a shot wide of the right upright, and Brazil keeper Julio Cesar had to scramble to his left post to turn a deflected Teko Modise shot wide after the interval.

Brazil pegged the home side back towards the end of the game without creating any real danger, but Alves finally broke the home team’s resistance as it seemed the game would go into extra-time.

Spain were still coming to terms with their shock 2-0 defeat against the US in Wednesday’s first semi-final.

The European champions were overwhelming favourites to reach the final, but turned in a flat, sluggish display against the well-drilled Americans – and suffered their first defeat since 2006.

A win or even a penalty shootout defeat against the US would have given Spain a new world record of 36 games without defeat. Now, they have to settle for sharing the record of 35 games with Brazil.

The US victory in Bloemfontein made rare headlines in the US who celebrated a first FIFA men’s final in US soccer history.

US newspapers called the shock result “the miracle on grass” – referring to the US hockey team’s upset defeat of the Soviet Union in the 1980 Lake Placid Olympics, a victory referred to as “the miracle on ice”.