Brazil were pushed all the way before prevailing against Japan by the odd goal in seven to reach the semi-finals for the seventh successive time.
Japan aiming for their first last-four appearance since 2005 pushed the four-time champs until the last seconds in an incredibly hard-fought contest.
Brazil started strongly but it was Japan that opened the scoring with Hirofumi Oda powering a shot home from the sideline.
The South Americans soon drew level after Eudin finished a sweeping move from close range.
Datinha put Brazil a goal to the good before the first break immediately after Ozu Moreira had hit the post for Japan.
Ozu then had an effort cleared off the line, and the player of the Asian qualifiers crashed home a penalty as Japan drew level.
The third and final quarter remained scoreless until the midway point as Daniel forced home from close range following Jorginho’s good lead-up work.
Many perhaps expected Brazil to remain in control, but Ozu Moreira soon equalised with a long-range effort helped in via a deflection of Bueno, with the goal later credited to the A Seleção defender.
Soon enough captain Bueno scored as Brazil took the lead for the third and final time.