Brazil came back to defeat Japan 2–1 and earn a place in the World Cup last 16.