Jose Mourinho’s Spanish champions will face off with English champions and heavily financed Manchester City.
Dutch champions Ajax are also in Group D and face Real at the group stages for the third successive season. Meanwhile, German champions Borussia Dortmund conclude the group, which is arguably the most eye-catching of the eight this season.
Barca, who lost in the semi-finals of the competition last season, tackle Benfica and Unai Emery’s Spartak Moscow, two sides who finished as runners-up in their respective leagues last term.
Completing Group G is Celtic, a team that the Blaugrana have met twice before in the competition, the last meeting being in the 2007-08 edition at the Last 16 stage.
Malaga, meanwhile, who are in the competition for the first time in their history, face tests against Milan, Zenit and Anderlecht for a place in the Last 16.
The six matchdays are scheduled to be played from the midweek of September 18/19 across to December 4/5.
Full Champions League draw
Porto, Dynamo Kiev, Paris Saint-Germain, Dinamo Zagreb
Arsenal, Schalke, Olympiacos, Montpellier
Milan, Zenit St Petersburg, Anderlecht, Malaga
Real Madrid, Manchester City, Ajax, Borussia Dortmund
Bayern Munich, Valencia, Lille, BATE
Barcelona, Benfica, Spartak Moscow, Celtic
Manchester United, Braga, Galatasaray, Cluj