Due to the floods in Valencia, Real hadn’t taken to the field since being thrashed 4-0 by Barcelona in El Clasico.
Far from a team looking to banish those demons, Los Blancos were sluggish out of the traps, and Milan made them pay by taking the lead inside the opening quarter-hour.
A set-piece proved the hosts’ undoing, as Christian Pulisic’s inswinging corner was powered home at the near post by Malick Thiaw for his first-ever goal for the Rossoneri.
An anxious Bernabeu crowd demanded a response, and as ever, Vinicius Junior provided it.
The Brazilian won a penalty when he was tripped by compatriot Emerson Royal, and stepped up to convert from 12 yards himself, totally deceiving Mike Maignan with a panenka-style spot-kick.
There was an air of inevitability about Real wrestling the game their way, but Paulo Fonseca’s men were having none of it, and after Tijjani Reijnders was denied by Andriy Lunin, the visitors hit the front again.
Aurelien Tchouameni gave the ball away cheaply, and once more Milan were ruthless as Rafael Leao’s shot on the turn was parried into the danger zone by Lunin, where Alvaro Morata was fastest to pounce and slot home against his former employers.
Carlo Ancelotti responded at the break, replacing Tchouameni and Federico Valverde with Brahim Diaz and Eduardo Camavinga.
Those changes had little impact though, as Real continued to lack potency in the final third while giving up chances at the other end.
Stand-in goalkeeper Lunin came to their rescue again within 10 minutes of the restart, producing a fine diving save to claw Leao’s header off target.
There was no sign of another classic Real comeback in the Champions League, and their revival hopes were put beyond them when the Rossoneri added a third.
A flowing team move culminated in the unplayable Leao bursting down the left and squaring for Reijnders, who composed himself before slotting through Lunin’s legs to seal a famous victory for Milan - their second in succession on Spanish soil.
Antonio Rudiger saw a late strike ruled out for offside on what was a miserable night for Madrid, who now have ground to make up in the race for automatic passage to the last 16.