City looked like they might snatch a Group D clash in which they had been outplayed when Aleksandar Kolarov struck late on.
But Madrid responded to the delight of the Bernabeu as Karim Benzema levelled and Ronaldo won it at the death.
The visitors had taken a 1-0 lead against the run of play through substitute Edin Dzeko in the second half but Marcelo quickly cancelled out the strike.
City boss Roberto Mancini had made a bold decision to hand a debut to new signing Matija Nastasic and leave Joleon Lescott on the bench, while fit-again striker Sergio Aguero was also among the substitutes.
David Silva and Gareth Barry also returned to the starting line-up, with Carlos Tevez playing alone up front.
Real went into the game in disappointing form after winning just one of their opening four Primer Liga matches.
Manager Jose Mourinho, under heavy scrutiny, promised not to make major changes but those he did make sent out a clear message.
It was not a surprise that playmaker Mesut Ozil failed to making the starting line-up after some criticism but the absence of defensive lynchpin Sergio Ramos was unexpected.
Raphael Varane came in at the back and looked composed, while Michael Essien's introduction in midfield ahead of another playmaker in Luka Modric added solidity.
There seemed little wrong with the side Mourinho fielded as they dominated possession throughout, but found goalkeeper Joe Hart in inspired form.
Former Manchester United star Cristiano Ronaldo twice tested Hart in the opening minutes, first after being released by Essien.
The Portuguese, booed loudly by City's vocal fans, cut inside Vincent Kompany but Hart was equal to his low effort.
Ronaldo then beat Maicon on the left to extend Hart again but City survived.
Alvaro Arbeloa then did well to beat Gael Clichy but Hart saved low down.
Angel di Maria lofted a cross in for Higuain but failed to make firm contact as Hart stood tall. The ball rebounded for Ronaldo to attempt a spectacular effort but it was deflected and Sami Khedira fired over.
City had an opportunity after a good break by Yaya Toure but Samir Nasri's effort was blocked.
It proved Nasri's last meaningful involvement as he limped off moments later to be replaced by Kolarov.
City went close again before half-time, Toure again instrumental in their break but David Silva was unable to get away a clean shot.
Real finished the first half strongly with Higuain volleying over and Di Maria bending a low shot wide.
The second half began in much the same manner with Marcelo flashing a shot wide and then firing over.
The Spaniards appeared to be completely monopolising possession but City broke away to open the scoring against the run of play in the 68th minute.
Toure was again the driving force and his ball for the newly-introduced Dzeko was perfect. The Bosnian took the pass in his stride and finished with great composure.
The lead could not last. Madrid produced a strong response and this time Marcelo got lucky as he cut inside and fired a shot past Hart, with the possible aid of a deflection off Javi Garcia.
The game then became a dramatic end-to-end affair and Hart produced another superb save to deny Higuain.
City were not content to sit back for a point and looked like they might snatch it when a Kolarov free-kick from the right crept through the box, taking a slight touch off Xabi Alonso, to hit the net with four minutes remaining.
However, Real sensed the urgency and powered forward in a pulsating finish.
Benzema, who replaced Higuain with 17 minutes remaining, turned brilliantly on the edge of the area and levelled with an equally composed finish. It was the least the hosts deserved - but Hart did not deserve to be beaten.
The England goalkeeper again showed his brilliance in the dying moments to save from Ronaldo - but the Bernabeu hero could not be kept out long and he fired in a low shot in injury-time.