The five-times world champions had been held to 0-0 draws in their last three home games, against Argentina, Bolivia and Colombia, and had not scored in front of their own fans since last November.
Dunga was jeered by the crowd and seemed to be in for a long night when Danny opened the scoring for the visitors by turning in Bruno Alves's cross after four minutes.
But Luis Fabiano levelled four minutes later following a break down the left by Robinho and put Brazil ahead in the 25th minute with a shot on the turn from Kaka's pass.
The second half produced four goals in a 10-minute spell.
Maicon scored with an angled shot for Brazil in the 55th minute and Luis Fabiano completed his hat-trick with an opportunist goal two minutes later.
Simao Sabrosa pulled one back for the visitors, only for Elano to rifle home Brazil's fifth from another chance created by Kaka.
Adriano headed Brazil's sixth in stoppage-time as Brazil completed their first win over Portugal since 1989.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.