“Today Real Madrid wants to give thanks to a player who has demonstrated he is the best in the world and who marked one of the most brilliant periods in the history of our club and world football,” the club said in a statement.
It did not give any details as to the amount of the transfer but Spanish media reports have said it could reach 105 million euros ($120 million), with the 33-year-old signing a four-year contract worth 30 million euros per season.
In a letter posted on Real Madrid's website, the multiple Ballon d'Or winner said his time in Madrid had been one of the happiest in his life.
“I only have feelings of huge thanks for this club, for the fans and for this city,” he said.
“But I think the time has come to open a new stage in my life and that's why I asked the club to accept to transfer me.
“I ask everyone, and especially our supporters, to please understand me.”
Ronaldo, whose Portugal were knocked out of the World Cup last 16 by Uruguay, hinted after May's Champions League victory against Liverpool that he was considering leaving the Santiago Bernabeu.
“It was very nice to be in Madrid,” he said at the time, using the past-tense. He later played down the statement, but doubts over his future at Madrid lingered.
Real Madrid has won the La Liga twice and the Champions league four times since Ronaldo moved there from Manchester United in 2009.