In a breathless game, Nani forced Sergio Ramos to put through his own goal in the 48th minute to give United a 2-1 aggregate lead in the last 16 tie, only for the Portuguese winger to then be sent off for a foul on Alvaro Arbeloa.
Madrid immediately seized the initiative, equalizing through substitute Luka Modric in the 66th minute and then earning victory through United old boy Ronaldo on his return to Old Trafford.
Madrid manager Jose Mourinho conceded his side had been fortunate to go through, telling ITV: "Independent of the (Nani) decision, the best team lost. We didn't deserve to win, but football is like this."
United's defeat meant that Ryan Giggs' 1,000th appearance in senior football ended in disappointment, while Madrid can dream of a 10th European title after reinvigorating their season in recent weeks.
United manager Alex Ferguson had sprung a major surprise by naming Wayne Rooney on the substitutes' bench, but Giggs was included in the starting XI as he became only the third British outield player to play in 1,000 games.
A wave of applause for Ronaldo rippled around the ground at kick-off and the Madrid number seven unexpectedly found himself in direct opposition to Giggs, who started the match in an unfamiliar role on the right flank.
Giggs roused the home fans with a determined run down the wing in the 20th minute and from the corner he won, United came within a hair's breadth of taking the lead.
Nemanja Vidic met Giggs' inswinging corner with a typically emphatic header that came back off the right-hand post and goalkeeper Diego Lopez reacted well to smother Danny Welbeck's instinctive follow-up.
Madrid then enjoyed a brief spell in the ascendancy, with Rio Ferdinand blocking from Ronaldo and goalkeeper David de Gea thwarting Gonzalo Higuain before Ramos had a goal ruled out for a foul on Robin van Persie.
The action soon swung the other way, however, with Lopez doing brilliantly to divert a shot from Welbeck over the bar after he had allowed a stinging effort from van Persie to get away from him.
Despite shading the first half in terms of opportunities, United had nothing to show for their efforts, but that changed within three minutes of the second period.
After Welbeck and van Persie had both seen shots blocked, Nani picked up the ball wide on the left and played a low cross into the Madrid six-yard box that Ramos inadvertently poked into his own net.
The Portuguese celebrated the goal as if he had scored it himself, but moments later, his night was over.
In attempting to control a high ball, he caught Arbeloa in the chest with his studs and was shown a straight red card by referee Cuneyt Cakir, much to Ferguson's evident displeasure.
United's manager came to the touchline to rouse the home support but Madrid had the momentum and Rafael da Silva had to bravely clear a Higuain header from below his own crossbar.
Van Persie worked Lopez with a low shot, but Madrid were quickly back on the attack and in the 66th minute, they levelled.
Mourinho had reacted to Nani's dismissal by introducing Modric in place of Arbeloa and the Croatian had an immediate impact, darting into space and arrowing a superb 25-yard shot past de Gea via the right-hand upright.
The turnaround was complete three minutes later and with poetic inevitability, it was Ronaldo who put Madrid ahead, touching in Higuain's low cross-shot and then pointedly apologising to the fans behind de Gea's goal.
Ferguson turned to Rooney and United went for broke, but Lopez saved from Michael Carrick and van Persie in quick succession before Rooney volleyed over.
Madrid substitute Kaka hit the post, before Lopez produced another stunning stop from Vidic to crown a decisive individual display.