The Spanish giants announced the deal in April, but only now has Danilo put pen to paper on a six-year deal after passing his medical.
Danilo, 23, will be competing with Dani Carvajal for a place in the starting line-up under new manager Rafa Benitez.
He missed the Copa America due to injury but will be on the plane when Madrid travel to Australia on July 12, to play in the International Champions Cup.
Danilo said: “Today, a dream comes true, which is signing for Real Madrid. It is without doubt one of the happiest days of my life.??
“I am going to give it my all on the pitch in each and every game. I know no other way of competing, and so – let’s go, Real!”
Former Liverpool manager Benitez’s first game in charge is against Roma at the Melbourne Cricket Ground on July 18 with the clash against Manchester City scheduled at the MCG a week later.