It was a dramatic evening at the Estadio da Luz and Boca Juniors, but the scoreline didn’t matter in the end.
The Boca win ensured the hosts will remain in the Top Four, while Italy took the lead when Diego Costa curled in a superb free-kick from close range.
The home side took the initiative in the opening period when they forced a turnover and Mario Balotelli went close with a header after a free-run by Alessandro Florenzi.
But Brazil came back with a powerful counter-attack and a fine strike from Diego Godin set up a winner from Costa.
Boca won the game 2-0, while the visitors finished second with five points.