Liverpool will have to overcome Hoffenheim in a two-legged playoff to reach the group stages of the Champions League.
The draw was made in Nyon on Friday with Liverpool forward Roberto Firmino's former club Hoffenheim, who finished fourth in the Bundesliga last season, drawing Jurgen Klopp's side out of the hat.
Liverpool, last winners of the Champions League in 2005, will be hoping to feature in the group stage for the first time since the 2014-15 season.
The first leg will be played at the Rhein-Neckar-Arena on Aug. 15, with the return fixture at Anfield scheduled for Aug. 23.
Istanbul Basaksehir vs. Sevilla
Young Boys vs. CSKA Moscow
Napoli vs. Nice
Hoffenheim vs. Liverpool
Sporting Lisbon vs. FCSB
Qarabag vs. Copenhagen
APOEL vs. Slavia Prague
Olympiakos vs. Rijeka
Celtic vs. Astana
Hapoel Be'er-Sheva vs. Maribor
Last season saw Liverpool finish in the Premier League's top four for only the second time in eight seasons.
Liverpool boss Klopp is looking forward to returning to Germany to face Hoffenheim, but he knows they will provide a stern test for his side.
"Very interesting," Klopp told Liverpool's official website of the draw. "Actually, it was exactly what I expected when I had a look -- if there's a choice we always seem to take the German team. Sorry!
"It was clear from the first moment when we knew who we could face that there would be no easy game. It's Hoffenheim and that's for sure not an easy game. But we should always not forget what they thought in the moment they saw the draw -- it's not the best thing they could get.
"I'm completely fine with it, happy to know and now we can start preparing. [They are a] strong side, how everybody can imagine. When you are fourth in Germany you are a strong side. It's a very interesting club. They have a lot of really good young players. They lost two of them -- [Sebastian] Rudy and [Niklas] Sule to Bayern Munich -- and had a little change. [They have] a very young manager, just 30 years old, a very talented man.
"That's a real challenge but I'm looking forward to it. First we'll play Watford [in the Premier League] but at the same time we'll start preparing for Hoffenheim and it's really exciting."
Hoffenheim head coach Julian Nagelsmann admits his side face a real challenge in qualifying for the group stage but he is excited about taking on the Premier League side.
"It's indeed a tough draw, but there wasn't really one easy draw," he told Hoffenheim's official website. "We can play against a great opponent in a legendary stadium. It's something special.
"Only this morning, I said that if you want to win the trophy you have to beat every opponent and so we also need to come out on top against Liverpool. I had a feeling it would be Liverpool and I think it's a great thing for both our fans and the media.
"Jurgen Klopp is back in Germany. I believe they would not have necessarily picked us as their opponents. We will give it our all to progress. Liverpool are an outstanding team. I already have an idea how we can achieve something, but we still need to see a couple of matches to work out a plan."
Hoffenheim sporting director Alexander Rosen added: "We are incredibly happy, that's something special. I was anxious before the draw. It's a great challenge, but we are just delighted to take part in it.
"Jurgen Klopp will be here, and Firmino returns. All of that turns a great situation into an absolutely special one. Our ambition will know no bounds. We will surely compete to reach the group stages."
Among the other fixtures from the League side of the draw is Napoli's tie against Nice, which will see Mario Balotelli return to Italy with his French side, while Sevilla take on Istanbul Basaksehir.
In the Champions section of the draw, Scottish club Celtic were drawn against Kazakh side Astana.
Celtic's reward for their third qualifying round victory over Rosenborg of Norway is to once again make the near 8,000-mile round trip to Kazakhstan.
Brendan Rodgers' side played Astana in the Champions League last season, drawing 1-1 in Kazakhstan before winning the return game 2-1.