City’s slim hopes of qualification going into the game depended upon results elsewhere and the Premier League champions winning their remaining two fixtures.
That looked unlikely when Karim Benzema took advantage of slack marking from Maicon to convert Angel Di Maria’s right-wing cross inside 10 minutes.
But City improved in the second half and the equaliser came from the penalty spot when Alvaro Arbeloa was adjudged to have pulled down Sergio Aguero in the box.
Arbeloa was given a red card for a second bookable offence and Aguero got up to convert the spot-kick, setting things up for an exciting finale.
There would be no fairy-tale turnaround for the home side though and they struggled to create another chance as Real held on to ensure their own passage into the last 16.
Jose Mourinho’s men had appeared in the mood to wrap things up quickly as they peppered the City goal early on and Sami Khedira should have added to the lead soon after the opener.
The Germany international danced past two challenges but then delayed his shot and Joe Hart came off his line to smother the ball at the midfielder’s feet.
City once again seemed uncomfortable with their 3-5-2 formation and Roberto Mancini switched to a back-four midway through the first half.
That produced a more upbeat performance and the home side carried that into their second-half display, nearly finding an equaliser just after the hour-mark when Iker Casillas denied Aguero from close range.
That equaliser did come in the end but it was not enough for City and they go out of the Champions League in the group stage for the second consecutive season.