Messi and Ronaldo will resume the rivalry they developed when the Portuguese superstar was at Real Madrid. Between them they have won 11 of the past 12 Ballons d'Or.
The two heavyweights were drawn in Group G along with Dynamo Kiev of Ukraine and Ferencvaros, the Hungarian club returning to the group stage for the first time in quarter of a century.
Meanwhile, beaten 2020 finalist Paris Saint-Germain will have a chance for revenge against Manchester United, which ousted the French club in the Round of 16 two seasons ago.
PSG will also come up against RB Leipzig in Group H. The sides met in last season's semi-finals in Lisbon in August, with Paris winning 3-0 before losing to Bayern Munich in its first final appearance.
Completing the group is Istanbul Basaksehir, which is appearing in the tournament proper for the first time.
English Premier League champion Liverpool, which won the UEFA Champions League in 2019, will face Ajax as well as Atalanta and Midtjylland of Denmark in Group D.
Holder Bayern will take on Atletico Madrid and will also have a short trip across the border to Austria to take on Salzburg in Group A. Lokomotiv Moscow is the other team in that section.
Other notable match-ups will see 13-time European champion Real Madrid meet Inter Milan in Group B and Chelsea come up against debutant Rennes as well as UEFA Europa League winner Sevilla in Group E.
Chelsea signed goalkeeper Edouard Mendy from Rennes last week.
The group stage starts on 21 October (AEST), and all six rounds of games will be crammed into eight weeks in a schedule that is even more packed than usual because of the coronavirus pandemic.
This season's final is scheduled to be staged in Istanbul, which was initially the host for last season's final before UEFA was forced into a change of plans because of the health crisis.
It remains to be seen whether spectators will be able to attend matches in the group stage.