Gareth Bale's stunning overhead kick to give Madrid a 2-1 lead in the 64th minute will go down in European soccer history.
So will Liverpool goalkeeper Loris Karius' two blunders to gift Madrid its other goals, scored by Karim Benzema and substitute Bale.
A goalless first half saw Liverpool star forward Mohamed Salah exit in tears with a shoulder injury in the 30th.
Benzema put Madrid ahead in the 51st when he intercepted an unwise attempt by Karius to roll the ball out to a defender.
Sadio Mane leveled in the 55th from close range after a corner. Bale got the decisive goal, then added his second in the 83rd when Karius fumbled a long-range shot into the net.