Mauricinho and Lucao put Brazil ahead before Egan-Osi Ekujumi gave the Super Sand Eagles a glimmer of hope with his tidy finish.
Rodrigo added a third with a driven left-footed finish into the far corner, but Nigeria were back to within one again when captain Azeez Abu carved out a one-on-one chance and finished confidently past Mao. However, Lucao got his second on the night with a precise volley.
Brazil pulled away completely in the third period as Rodrigo completed a hat-trick, highlighted by an impressively-high bicycle kick, while Bokinha scored a brace and Rafinha, Bruno Xavier, Catarino and Filipe all got on the scoresheet.
Brazil will face Russia in the quarter-finals after the Russians finished in second place in Group C.