The Spanish club acquired the 19-year-old midfielder for around £15m, though the deal also includes around £6.5m in add-ons and a 15% fee if he is sold on.
“This is the most important day in my life,” Diaz told reporters on Monday.
“I have joined the club which I have dreamed of playing at since I was a child,” he added.
“When I decided it was time to leave Manchester City I only considered three options: the first was joining Real Madrid, the second was playing at Real Madrid and the third and last was playing at Real Madrid. I didn’t want to go anywhere else.”
Diaz, who joined Manchester City from Malaga in 2013 aged 14, has signed a six-and-a-half-year contract that runs to the summer of 2025.
He only made 15 first-team appearances during his time at City and played just four times this season.
Madrid president Perez said:
“This player has a special talent. He has quality, magic and dreams of succeeding at this club. He chose it above others and that energy will help.”
Diaz is the latest young player to leave Manchester City in recent seasons, with departures including winger Jadon Sancho, who has starred for England since moving to German side Borussia Dortmund for £8m in 2017.