Neymar scored for the third straight Confederations Cup game, curling in a delightful free kick, as Brazil beat Italy 4-2 to complete Group A with a perfect record on Saturday.
Dante, who replaced the injured David Luiz, put Brazil ahead in first-half stoppage time but Emanuele Giaccherini levelled six minutes after the re-start after being sent clear by Mario Balotelli's clever back-heeled flick.
With both teams already qualified for the last four from Group A, Neymar put Brazil back in front four minutes later and Fred added a third after he was found by Marcelo's raking pass in the 66th minute.
A pulsating game took another twist when Giorgio Chiellini replied for Italy five minutes later with Brazil claiming the referee had already stopped play before the defender turned the ball in. Italy, who won their first two games, were caught on the break as Fred added a fourth in the 89th minute.