© PA Photos
The contest looked as though it would be a tight affair in the opening stages but poor defending from the hosts gifted the opening goal to Madrid.
The visitors had numerous chances to extend their lead before the break, with Sami Khedira twice missing the target from inside the box.
© PA Photos
Cristiano Ronaldo looked certain to double his side's lead when he accelerated away from the City defence but his chip was cleared off the line by Matija Nastasic, allowing the home team to clear the danger.
Both teams had opportunities to score on the stroke of half-time, with Sergio Aguero seeing his shot tipped over the crossbar by Iker Casillas before Khedira was once again frustrated, this time by the reactions of Hart.
City improved after the interval but failed to create many clear opportunities with the visiting defence remaining solid.
When a chance finally fell to the feet of a City player, Casillas was on hand to react to keep out Aguero's effort from close range.
© AP Photos
The Premier League champions were given a way back into the match with 18 minutes remaining when Alvaro Arbeloa conceded a penalty following a challenge on Aguero and despite the minimal contact, the Spaniard was shown a second yellow card and given his marching orders.
Aguero stepped up from 12 yards to slot the ball past Casillas and increase hopes of an unlikely victory.
However, Madrid held on for a point to confirm qualification, knocking out their opponents in the process.