The Spanish giants released a statement to confirm they had accepted Ronaldo's request to move to Italy in a deal worth €100m (£88m/$117m) plus €12m (£10.5/$14m) in additional charges.
The five-time Ballon d'Or winner said his farewells to Madrid in a letter published on the La Liga club's website.
"These years at Real Madrid, and in this city of Madrid, have been possibly the happiest of my life," the 33-year-old said.
"I only have feelings of enormous gratitude for this club, for this sport and for this city. I can only thank all of them for the love and affection I have received.
"However, I believe that the time has come to open a new stage in my life and that is why I have asked the club to accept transferring me. I feel that way and I ask everyone, and especially our followers, to please understand me.
"They have been absolutely wonderful for nine years. They have been nine unique years. It has been an exciting time for me, but also hard because Real Madrid is very demanding, but I know very well that I will never forget that I have enjoyed football here in a unique way.
"I have had fabulous team-mates on the field and in the dressing room, I have felt the warmth of an incredible crowd and together we have won three Champions Leagues in a row - and four in five years.
"Real Madrid has conquered my heart, and that of my family, and that is why more than ever I want to say thank you: thanks to the club, the president, the directors, my colleagues, all the technicians, doctors, physios and incredible workers that make everything work and that are pending every detail tirelessly.
"Thank you infinitely once more to our fans, and thanks also to Spanish football. During these nine exciting years I have had great players in front of me. My respect and my recognition to all of them."
Ronaldo became the world's most expensive player when he joined from Manchester United in 2009, going on to become Madrid's all-time leading scorer.
"I have reflected a lot and I know that the time has come for a new cycle," he continued.
"I'm leaving but this shirt, this badge and the Santiago Bernabeu will continue to always feel my own wherever I am.
"Thanks to all and, of course, as I said that first time in our stadium nine years ago: Hala Madrid!"