The hosts of Rio 2016 are through to the quarter-finals of the men's football tournament, but Mexico and Argentina bowed out on Wednesday.
Brazil finally hit the goal trail in the men's football tournament at Rio 2016 to avoid an embarrassing group-stage exit on home soil.
The tournament favourites had surprisingly drawn blanks in 0-0 draws against South Africa and Iraq, but had no such problems when beating Denmark 4-0 in Salvador.
First-half strikes from Gabriel Barbosa and Gabriel Jesus eased the tension at the Fonte Nova Arena and Luan rounded off a fine move in the second half to put the result beyond doubt.
There was a late scare for Brazil when Neymar went down in pain after appearing to twist an ankle, but the Barcelona forward was able to continue and saw Gabriel Barbosa score again late on.
Brazil will take on Colombia in the last eight, while Denmark are also through - after South Africa and Iraq drew 1-1 - and will play Nigeria.
Colombia beat Nigeria 2-0 on Wednesday to join the African nation in progressing from Group B and deny Japan, 1-0 winners over Sweden.
Reigning champions Mexico and Argentina each bowed out of the competition on Wednesday, while Germany progressed courtesy of a 10-0 trouncing of Fiji.
Mexico finished third in Group C after suffering a 1-0 defeat in Brasilia to South Korea, who now face Honduras.
The latter qualified at Argentina's expense following a 1-1 draw between the two nations. Group D winners Portugal, Germany's last-eight opponents, rounded off their pool campaign by sharing the spoils with Algeria.
The relief inside the Fonte Nova Arena was clear when Gabriel Barbosa converted a Douglas Santos cross to end Brazil's goal drought. The forward rushed toward the stands to celebrate with fans and it was not long before the hosts were in complete control.
PLAYER OF THE DAY
Nils Petersen certainly enjoyed himself against hapless Fiji, scoring half of Germany's 10 goals.
QUOTE OF THE DAY
The great Pele was in optimistic mood as Brazil began their match against Denmark, tweeting: "One victory can change our path for the desired #Gold medal."
It's knockout football from now on, starting with the women's quarter-finals on Friday.