The Seleção were 3-0 up after an hour thanks to goals from Leo, Ademilson and Adryan and seemingly in cruise control. However, Japan fought back, scoring through Shoya Nakajima and Fumiya Hayakawa to set up a tense finish.
Ultimately though it was not enough, and Brazil were able to hang on to progress to the last four of the competition in Mexico. They will now face Uruguay for a place in the final, who beat Uzbekistan 2-0 in the quarter-finals.
That game is scheduled for July 7 in Guadalajara, while the final is three days later in Mexico City.