Danilo, 23, will join his new team after the end of this season on a six-year contract.
Real Madrid had long been rumored to be interested in the young defender. "I'm happy to be associated with great clubs like Real Madrid," he told reporters last week.
Real Madrid's current right backs are 23-year-old Dani Carvajal and 32-year-old Alvaro Arbeloa.
Danilo, whose full name is Danilo Luiz da Silva, first joined Portuguese side Porto in 2012 and has helped lead the club to the Champions League quarterfinals this season. He made his first appearance with the Brazilian national team in 2011 at the age of 20. He remains a part of the team, assisting on the lone goal in Brazil's 1–0 win over Chile on Sunday.
- Dan Gartland