Japoan made a very qiuck start to the contest and were 2-0 ahead in 20 minutes as Keito Nakamura and Takefusa Kubo found the back of the net.
Brazil though showed why they are a football superpower and hit back 10 minutes before the halftime break when Real Madrid star VinÃcius slammed an effort home.
The forward then stamped his authority on the game and found the equaliser with 15 minutes remaining and the South American giants were now searching for the winner.
Brazil head coach Carlo Ancelotti brought Endrick for Raphinha off the bench to add more attacking impetus but it was to no avail as Sakamoto scored in the first minute of added time to give Japan a famous victory.
The Seleçao disputed it over an alleged foul on Joao Gomes that went unpunished at the start of the move leading to Japan's goal.
Ancelotti and Raphinha confronted the referee after the final whistle and player and caoch was shown red cards as it all ended on a sour note for the Brazilians.