(CNN) -- Brazil thrashed Italy 3-0 to send the world champions home from the Confederations Cup as the United States also reached the semifinals after beating Egypt 3-0 in the other Group B match on Sunday.
Luis Fabiano showed his goalscoring instinct with an excellent first half double.
The 2006 World Cup winners trailed 3-0 at halftime in Pretoria to a Kaka-inspired Brazil as a Luis Fabiano double and an Andrea Dossena own goal dealt them a hammer blow.
Brazil could afford to take the foot off the pedal after the break, but Italy could not score the goal which would have put them through.
The U.S. had needed a six-goal swing to go through and strikes from Charlie Davies, Michael Bradley and Clint Dempsey in Rustenberg saw them home in a remarkable turnaround.
The win meant the U.S., Italy and Egypt all finished on three points, well behind Brazil on nine.
Egypt's goal difference was minus three, ruling them out, while Italy and the U.S. finished on minus two but the States went through by virtue of scoring one more goal.
African champions Egypt, who beat Italy in their previous group match, were outplayed by their opponents, who will play Spain in the semifinals.
Five-time world champions Brazil will take on hosts South Africa for a place in the final.
Italy captain Fabio Cannavaro matched Paolo Maldini's record for most national team appearances with his 126th cap, but the 35-year-old endured a miserable evening as their ageing team wilted.
Brazil hit the woodwork twice before Fabiano made the breakthrough in the 37th minute as latched on to a shot driven into the Italy penalty area and beat Gianluigi Buffon with ease.
Real Madrid's new signing Kaka was at the heart of Brazil's play and his neat cross was left by Robinho for Fabiano to score his second just six minutes later.
The third came as Robinho burst down the right and his low cross was diverted past the unfortunate Buffon by the outstretched Dossena.