Mark Uth netted a tie-saving goal for Hoffenheim with three minutes left, but Liverpool will be delighted with their result and performance against a team who went through last season without suffering defeat in front of their own supporters.
Both teams made a bright opening at the Wirsol Rhein-Neckar-Arena but Hoffenheim were gifted the opportunity to take the lead in the 11th minute when the official behind the goal ruled that Dejan Lovren had tripped Serge Gnabry in the penalty area.
After that reprieve, Liverpool should have gone ahead through Mohamed Salah but after breaking clear of the defence, the summer signing directed a weak shot wide of the post.
Both teams were having their moments in the respective final thirds but with 11 minutes of the first half remaining, Liverpool went ahead thanks to a sensational free kick from Alexander-Arnold, who curled his strike into the bottom corner from 30 yards out.
Hoffenheim remained the better side heading into the break but Liverpool somehow managed to hold on to their advantage when Mignolet blocked from Gnabry before Sandro Wagner dragged a shot against the woodwork from 20 yards.
Jurgen Klopp would have been desperate to get his players back into the dressing room although with the final touch of the opening 45 minutes, the Premier League outfit should have doubled their lead through Lovren, but his header from 10 yards narrowly missed the far corner.
Two minutes after the restart, Liverpool created another huge opportunity but former Hoffenheim attacker Roberto Firmino somehow hit his close-range effort from a Sadio Mane cross straight at Oliver Baumann.
Mane was having an increasing influence on the game and the winger almost netted a stunning second for his team after cutting inside onto his right foot before Baumann again came to the rescue for Hoffenheim.
The hosts began to have the majority of possession but over a 15-minute period, Julian Nagelsmann's outfit failed to create any opportunities of note and it only encouraged Liverpool to up their attempts to score a second.
Salah and Lovren both sent efforts straight at Baumann from inside the penalty area but with 16 minutes left, the visitors doubled their lead when Milner's cross was deflected into his own net by former West Ham player Nordtveit.
Liverpool remained keen to push for a third but with three minutes remaining, Hoffenheim halved the deficit through a fantastic effort from Uth, who controlled a high ball before drilling a half-volley into the bottom corner from 16 yards.
In the first minute of added-on time, Hoffenheim should have been level when Benjamin Hubner was found all on his own inside the penalty area but a free header was directed over the crossbar from 10 yards out.
It proved to be Hoffenheim's final opportunity of a thrilling game, and it leaves Liverpool as the favourites to progress through to the group stages in next week's second leg.