Wayne Rooney's stunning last-minute winner kept Manchester United's hopes of reaching the Champions League final alive after an Old Trafford classic.
Man Utd players celebrate Wayne Rooney's equaliser at Old Trafford
Cristiano Ronaldo's fifth-minute header put United in front, only for AC Milan to draw level through Kaka's angled drive after 21 minutes.
Kaka put Milan ahead from close range before the interval, but Rooney turned in Paul Scholes' cool pass on the hour.
Rooney then lashed a glorious 20-yard finish past Dida in injury time.
It was a moment of magic that gave United a precious lead to defend going into the second leg in Milan next Wednesday.
United opened in sparkling fashion, and it took a desperate intervention from Alessandro Nesta to divert Rooney's shot over the bar.
But they were soon ahead when Ronaldo met Ryan Giggs' corner with a firm header, which Dida palmed into the air and could then only divert into the net.
United were firing on all cylinders up front - but all the time Milan, in the shape of Kaka, were waiting to probe their suspect and under-strength rearguard.
And the strike they feared came after 21 minutes when Kaka took Clarence Seedorf's pass and accelerated away from Gabriel Heinze and fired a left-foot angled drive across Edwin van der Sar.
A high-quality encounter saw Rooney just fail to get on the end of Giggs' cross and Ronaldo bring a crucial block from Dida with a 25-yard power drive.
But Brazilian superstar Kaka was an ever-present threat, and he took advantage of shambolic United defending to grab a crucial second away goal for Milan after 36 minutes.
Kaka chased a long pass, and when Heinze and Patrice Evra collided, he moved smoothly into top gear to slide a perfect finish past Van der Sar.
Evra was then booked for dissent - a yellow card that rules him out of the second leg at the San Siro, an inconvenience United did not need given their lack of defensive resources.
Michael Carrick wasted a glorious opportunity to put United level after 47 minutes when he side-footed wide of an open goal when he arrived unmarked at the far post on the end of another dangerous Giggs corner.
Milan lost captain Paolo Maldini to a knee injury at half-time, then were robbed of Gennaro Gattuso with a knee problem - with the combative midfield man being replaced by Cristian Brocchi.
Kaka was giving a master-class, escaping the offside trap to shoot across the face of goal then playing a sumptuous one-two with Seedorf only to volley narrowly over.
United desperately needed inspiration, and a moment of genius from Scholes provided it as they drew level after 59 minutes.
Scholes instinctively lifted the ball into the path of Rooney, whose finish was half-stopped by Dida but rolled in.
United were suddenly buoyant again, and the unpredictable Dida saved brilliantly from Darren Fletcher after Rooney's cross was headed into his path.
Fletcher forced Dida into a save at his near post as United pressed for what would be a crucial lead to take to Italy.
Dida then finger-tipped Ronaldo's dipping drive inches wide as United mounted a spell of sustained pressure in the closing stages.
United's sheer courage was rewarded when Rooney ran on to Giggs' pass and fired past a startled Dida to send Old Trafford wild in celebration.
Man Utd: Van der Sar, O'Shea, Brown, Heinze, Evra, Fletcher, Carrick, Scholes, Ronaldo, Rooney, Giggs.
Subs Not Used: Kuszczak, Smith, Solskjaer, Dong, Richardson, Eagles, Lee.
Booked: Evra, Giggs.
Goals: Ronaldo 6, Rooney 59, 90.
AC Milan: Dida, Oddo, Nesta, Maldini (Bonera 46), Jankulovski, Gattuso (Brocchi 52), Pirlo, Ambrosini, Seedorf, Kaka, Gilardino (Gourcuff 84).
Subs Not Used: Kalac, Cafu, Inzaghi, Favalli.
Booked: Kaka, Bonera.
Goals: Kaka 22, 37.
Ref: Kyros Vassaras (Greece).