The five-time world player of the year had seemed set to sign for rivals Manchester City.
United announced shortly before 5pm on Friday they had secured a deal with Juventus for the Portugal star that was subject to the agreement of personal terms, a medical and a visa.
It capped a remarkable turn of events after reports just hours earlier had suggested the 36-year-old five-time world player of the year was poised to sign for rivals Manchester City.
United said in their announcement: “Everyone at the club looks forward to welcoming Cristiano back to Manchester.”
The PA news agency understands United will pay 15million euros (£12.85million) plus eight million euros (£6.85m) in potential add-ons.
Ronaldo scored 118 goals in 292 appearances for United between 2003 and 2009 before leaving Old Trafford for Real Madrid, where his successes included four Champions League triumphs.
Former United manager Ferguson signed Ronaldo from Sporting Lisbon as an 18-year-old and Rio Ferdinand suggested he played a key role in the Portuguese star returning to Old Trafford.
“Cristiano and Sir Alex Ferguson have got a bond,” ex-United defender Ferdinand said on his YouTube channel when revealing he and Ronaldo had been in close contact as the move back to the Premier League neared on Thursday.
“Very few players get to have that in their career with a manager. Sir Alex played a massive part.
“There was no way Cristiano was coming to Man United without speaking to Sir Alex. Simple as that.”
For their part, United had not been looking to sign Ronaldo but seized the opportunity when it became clear he wanted to leave Juve.
That a move would be happening was all but confirmed on Friday morning when coach Massimiliano Allegri revealed Ronaldo had asked to leave Juve.
At this point City appeared the front-runners, but news conferences held by Guardiola and United boss Ole Gunnar Solskjaer early afternoon changed the picture.
While Guardiola poured cold water on the speculation, Solskjaer invited Ronaldo to sign for United. Perhaps dropping heavy hints something was afoot, the Norwegian said Ronaldo “knows that we’re here” and added midfielder Bruno Fernandes had been speaking to his compatriot.
It emerged soon after that United were in discussions with Ronaldo’s agent Jorge Mendes and City confirmed they had ended interest.
“I didn’t think Cristiano was going to turn out leaving Juventus,” Solskjaer said.
“We’ve always had a good communication – I know Bruno has been talking to him as well. He knows what we feel about him and if he was ever going to move away from Juventus, he knows that we’re here.
“He’s such a tremendous human being as well, so let’s see what happens with Cristiano. Everyone who has played with him, I think, has a soft spot for him.”
Ronaldo posted a farewell message to Juventus on Instagram, writing: “Today I depart from an amazing club, the biggest in Italy and surely one of the biggest in all of Europe. I gave my heart and soul for Juventus and I’ll always love the city of Turin until my final days.
“The ‘tifosi bianconeri’ always respected me and I tried to thank that respect by fighting for them in every game, every season, every competition. In the end, we can all look back and realize that we achieved great things, not all that we wanted, but still, we wrote a pretty beautiful story together.
“I will always be one of you. You are now part of my history, as I feel that I’m part of yours. Italy, Juve, Turin, tifosi bianconeri, you’ll always be in my heart.”
United players took to social media to welcome Ronaldo back to the club he joined in 2003 and where he spent six successful seasons.
Ronaldo’s Portugal team-mate Fernandes tweeted: “‘Agent Bruno’?” alongside emojis of a briefcase and a face with tears of joy before adding a cartoon of what appeared to be Fernandes as a youngster watching Ronaldo alongside the caption “Never stop dreaming…”.
United’s summer signing Jadon Sancho and fellow England internationals Marcus Rashford and Jesse Lingard were among a host of current United players to tweet about Ronaldo.
Roy Keane, who was United captain when the club first signed Ronaldo, wrote on Instagram: “Welcome back Cristiano”, while Edwin van der Sar posted on his account: “How are you feeling @manchesterunited fans? Always dreamt but never expected that it would happen! Welcome back in Manchester @cristiano”.
Gary Neville, another former team-mate, told Sky Sports: “It’s fantastic news. What they’ve done is bolster the squad with a proven goalscorer, a club legend. He will score goals and give them brilliant moments.”