Madrid's Ronaldo and Barcelona star Messi have been regarded as the best two players in the world for the best part of a decade, winning eight Ballon d'Or awards between them.
And Ancelotti, who guided Madrid to Champions League glory with the help of Ronaldo in 2014, believes the rivalry between the pair motivates both players to keep improving.
"I always get asked about Lionel Messi and how Cristiano regards him," Ancelotti, who will take over at Bayern Munich ahead of the new season, wrote in The Telegraph. "The truth is, we did not spend all our days at Madrid talking about Messi.
"Cristiano respects Messi; he respects him a lot. In a way I think they need one another. Each one pushes the other to new heights, to new records of goalscoring.
"Ronaldo signed for Manchester United in 2003 and played his first international tournament in 2004. Twelve years on he is still the biggest European star. That's incredible.
"Were it not for the other, one of Cristiano or Messi would probably have won the Ballon d'Or eight times, rather than three for one and five for the other. Or perhaps they would not have flown so high without the other pushing them on.
"As a manager it was a pleasure to be in charge of Ronaldo. He wanted to play every week and he wanted to score every week. I never went to bed the night before a match worrying about whether he was going to be ready."
Ronaldo is leading Portugal at Euro 2016 and, after struggling to make his mark on the country's opening two matches, he scored two goals in a 3-3 draw with Hungary on Wednesday.
Ancelotti says Ronaldo considers the chance to play for Portugal a privilege and knows the attacker would dearly love to add international silverware to an already glittering CV.
"He cares a lot about Portugal. You can see that he never swerves a game," he added.
"His best friends in the dressing room when I was there [at Madrid] were the other Portuguese players, Pepe and Fabio Coentrao. If he was Spanish he would have won two European Championships and a World Cup by now, perhaps even more.
"Playing for Portugal is fundamental to him. He would like to win something on the international stage, but very few do, and if it does not work out – well, that happens.
"The point is that he showed his country that he cares about Portugal, that it matters to him as much as anything else. Sometimes, as a great player you have to be happy with that and that alone. It is not like you can change your country, even if you wanted to."
Portugal meet Croatia in the round of 16 on Saturday in Lens.