The 19-year-old put pen to paper on a contract that runs until 2025 and will undergo a medical Monday before being unveiled at the Santiago Bernabeu.
Although neither side disclosed terms of the agreement, it's believed that Diaz was sold for a fee worth up to £22 million.
The teenager made 15 senior appearances for City after joining the Premier League side in 2015. He scored two senior goals, both of which came in City's 2-0 win over Fulham in the League Cup in November.
Diaz was reportedly frustrated by a lack of opportunities under City manager Pep Guardiola, who was hopeful that the midfielder would sign a new deal in November.
His departure marks the second major exit by a City youth player following the transfer of Jadon Sancho, who left in 2017 to join Borussia Dortmund. Sancho has flourished with the German side, scoring six goals and providing eight assists for the Bundesliga leaders.
Real Madrid suffered a shock 2-0 loss to Real Sociedad on Sunday, leaving them in fifth place in La Liga with just 30 points - 10 points back of leaders Barcelona - through 18 matches.