A statement on Real's website read: "The player will be tied to Real Madrid for the next six seasons. He will be presented on 6 July at the Santiago Bernabeu."
Ferguson was full of praise for the former number seven who had been talking of leaving for over two years.
"Cristiano has been a marvellous player for Manchester United," he said.
"His six years at Old Trafford have seen him develop into the best footballer in the world."
"His contribution has been a major factor in the club's success in that time and his talent, his ability to entertain and his infectious personality have enthralled fans the world over."
The BBC understands that the midfielder will earn about £11m per year, which will make him the highest paid footballer in the world. He was allegedly on about £6.38m at Old Trafford.