Alexis Mac Allister headed in the only goal, but Madrid were grateful to goalkeeper Thibaut Courtois for keeping the score down.
Trent Alexander-Arnold was met with a hostile reception on his return to Liverpool as a late substitute and the home crowd roared the Reds over the line for what could be a turning point in their season.
Both sides are now tied on nine points from their opening four games of the league phase. Liverpool had lost six of their last eight games in all competitions, but stopped the rot by beating Aston Villa on Saturday.
Florian Wirtz replaced Cody Gakpo in the only change from the weekend and Liverpool again looked more like the side that stormed to the Premier League title last season.
Madrid had lost just twice in 20 games since former Liverpool favourite Xabi Alonso took charge.