Five-times European champions Liverpool will face 10-times winners face Real as well as Basle and Ludogorets - the Bulgarian side who had a fairy-tale win in the play-offs - in Group B while there was a familiar look to the draw for the three other English sides.
Manchester City have perhaps the toughest group - they will face Bayern Munich for the third time in four years - plus CSKA Moscow and Roma in Group E, while Arsenal will play Borussia Dortmund for the second year running as well as Galatasaray and Anderlecht in Group D
In Group G, Chelsea will play German side Schalke for the second consecutive season plus Sporting Lisbon and Maribor.
Real Madrid may be a daunting prospect for Brendan Rodgers' side, but Liverpool beat the Spanish giants 5-0 on aggregate in 2009 including a 4-0 hammering at Anfield.
The draw in full:
Group A: Atletico Madrid, Juventus, Olympiakos, Malmo
Group B: Real Madrid, Basel, Liverpool, Ludogorets Razgrad
Group C: Benfica, Zenit St Petersburg, Bayer Leverkusen, Monaco
Group D: Arsenal, Borussia Dortmund, Galatasaray, Anderlecht
Group E: Bayern Munich, Manchester City, CSKA Moscow, Roma
Group F: Barcelona, Paris St-Germain, Ajax, APOEL Nicosia,
Group G: Chelsea, Schalke, Sporting Lisbon, Maribor
Group H: Porto, Shakhtar Donetsk, Athletic Bilbao, BATE Borisov