The CBF said the Manchester City full-back had suffered ligament damage in his left ankle after twisting it in training on Thursday, ahead of Friday's quarter-final against Belgium in Kazan.
Danilo had only just recovered from a hip injury that had ruled him out of Brazil's last two group games, with Fagner stepping up to take his place in the side and keeping it for the last-16 win over Mexico.
The CBF said that Danilo would not have the time to recover from the injury should Tite's side beat Belgium and advance to the semi-finals.
However, the 26-year-old has asked to stay with the squad as Brazil bid to win a record-extending sixth World Cup.
Danilo had started out as Brazil's first choice at right-back in Russia after Dani Alves was ruled out of the tournament with a knee injury.