In Real's first outing since the 4-0 humbling here against Barcelona, Carlo Ancelotti's men made the worst possible start, falling behind inside a quarter of an hour through Malick Thiaw's header.
Vinicius Junior's penalty midway through the first half looked like it would kickstart another Los Blancos comeback, but the home crowd were stunned when former Real striker Alvaro Morata put the Rossoneri back in front.
There was further shock for the 83,000-capacity crowd, as Tijjani Reijnders finished off a fine Milan move to double the visitor's lead with just under 20 minutes remaining.
Milan could have had more as Rafael Leao was denied brilliantly by Andriy Lunin and also struck the post from a corner, while Kylian Mbappe was guilty of passing up a golden opportunity at the other end.
Antonio Rudiger thought he had halved the arrears with eight minutes remaining when he fired home in the aftermath of a set piece, but following a lengthy VAR review, the goal was chalked off for offisde.
Real kept the pressure on, but Paulo Fonseca's side were able to deal with it relatively comfortably, as Mike Maignan made a few fine saves during six minutes of injury time.
The home side were booed and whistled on the half-time whistle, and those jeers intensified tenfold when the final whistle was sounded by referee Slavko Vincic, as Real suffer a second straight home defeat.
An excellent performance will ease the pressure on Fonseca at Milan, who have moved level on points with Real in the 36-team standings, sitting just one place below on goal difference.
REAL MADRID VS. AC MILAN HIGHLIGHTS
Thiaw goal vs. Real Madrid (12th min, Real Madrid 0-1 AC Milan)
Another awful start for Real as they go behind for the third straight game, with Christian Pulisic's in-swinging corner met by Thiaw, who got in between Eder Militao and Aurelien Tchouameni to head the visitors in front.
Vini Jr penalty vs. AC Milan (23rd min, Real Madrid 1-1 AC Milan)
Real are back in business, as Vini Jr is fouled in the area by Emerson Royal, and the Real Madrid man dusted himself down to nonchalantly dink his penalty down the middle beyond Maignan in the Milan goal.
Morata goal vs. Real Madrid (39th min, Real Madrid 1-2 AC Milan)
Alarm bells ringing again! Milan are back in front and it is Real Madrid old boy Morata who has pounced first for a simple tap in after Lunin could not hold onto Rafael Leao's snapshot after good work once again from Pulisic.
Reijnders goal vs. Real Madrid (73rd min, Real Madrid 1-3 AC Milan)
The Bernabeu can barely believe it! Milan go 3-1 up as excellent footwork from Reijnders sees him breeze away from Militao and Eduardo Camavinga, before a smart one-two with Leao leaves him one-on-one with Lunin and the Dutchman makes no mistake in front of goal.
MAN OF THE MATCH - RAFAEL LEAO
There were many candidates in the Milan ranks for this gong, as Pulisic and Reijnders were phenominal, but it has to go Leao, who once again showed that he is utterly unstoppable on his day, and gave Lucas Vazquez a torrid night at right-back for the hosts.
The Rossoneri number 10 played a big role in the second goal, and it was his fine footwork and vision that created the third, as Leao was also a constant threat on the counter against a Real Madrid defence that were run ragged all evening.
REAL MADRID VS. AC MILAN MATCH STATS
Possession: Real Madrid 56% - 44% AC Milan
Shots: Real Madrid 23 - 14 AC Milan
Shots on target: Real Madrid 10 - 9 AC Milan
Corners: Real Madrid 8 - 5 AC Milan
Fouls: Real Madrid 11 - 9 AC Milan
BEST STATS
WHAT NEXT?
Real will look to bounce back from another shocking home result when they welcome an overachieving Osasuna side to the Bernabeu on Saturday, while Milan go to Sardinia to face relegation candidates Cagliari in Serie A before the international break.