The 26-year-old will now link up with City on their pre-season tour of the United States after agreeing personal terms and passing his medical.
"There has been strong interest from other clubs, but it has always been my ambition to play for Pep Guardiola," Danilo told his new club's official website. "As soon as I heard of his interest, I knew immediately I wanted to be a City player.”
His departure from the European champions had been confirmed by Real boss Zinedine Zidane on Saturday on the eve of his team's meeting with Manchester United in California.
According to the BBC, he moves to Manchester on a £26.5 million deal.
Guardiola had made full-backs his top transfer priority in the close season having released Pablo Zabaleta, Gael Clichy and Bacary Sagna.
Danilo links up with City's new recruit Kyle Walker, the Tottenham defender who signed a five-year contract for a fee that could rise with add-ons to £54 million this month.
Juventus confirm Alves’ departure after just one season
Danilo, who joined European champions Real in 2015 from Porto, started just 17 Spanish league games last season with Dani Carvajal often preferred in the right-back role.
The Spanish international started ahead of Danilo in the Champions League final in Cardiff as Real Madrid beat Juventus 4-1 to lift their 12th European Cup.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ