Sofiane Boufal gave Morocco the lead before Brazil skipper Casemiro scored in the 67th minute.
Brazil’s fate was sealed after Abdelhamid Sabiri struck the winner in the 79th minute to record their first-ever win over the five-times world champions.
Brazil’s interim coach Ramon Menezes declined to participate in the press conference after the defeat but Morocco’s Head Coach was very happy with the outcome.
The next match for Morocco will be against Peru on Tuesday.