The Spanish champions dominated play, but Madrid side needed a late goal from the Portuguese forward to steal the points.
Champions League: Ronaldo rescues Real in five-goal thriller in Spain
The Spanish champions dominated play, but Jose Mourinho's side needed to score three times to snatch a late victory after substitutes Edin Dzeko and Alexsander Kolarov gave the English champions hope of a stunning victory. Goals from Real's Marcelo and Karim Benzema brought Madrid level before Cristiano Ronaldo scored the last minute winner.
Real may be out of form with just one league victory from four games, but they showed continued attacking intent lacking in recent matches and supposedly "sad" Ronaldo received a standing ovation from the 75,000 crowd as he left the field.
With Real favouring their usual 4-2-3-1 formation and City switching to a more defensive 4-1-4-1, the home side's positive tactics were obvious from the start. After eight minutes, Ronaldo cut inside Vincent Kompany and curled a low shot, forcing a diving save from Joe Hart.
As the visiting fans taunted Madrid by calling them a poor Barcelona, so the home team wasted two chances to take the lead in the 20th minute, Gonzalo Higuain springing the offside trap before being forced wide by Hart. The ball then fell to Ronaldo whose shot was deflected into the path of Sami Khedira but the midfielder blazed over from six yards to the anguish of his team mates.
Enjoying only 37 per cent of first-half possession, City were stretched but not entirely overawed on their Bernabeu debut.
Marshalled by captain Kompany, they defended well - and in numbers - against the incessant white-shirted attacks, but the former Barcelona midfielder Yaya Toure had the pace to bring the ball forward and concern Real with a counter attack undone by a poor final ball to David Silva.
Real increased the pressure, Xabi Alonso's passing accurate and swift, Angel Di Maria's quick feet troublesome for the blue defence, but Higuain profligacy in front of goal only matched by Hart's excellence. City were fortunate to reach half time without conceding.
Real resumed their dominance in the second half. As Jose Mourinho hollered instructions from the side, the mood ebbed and flowed among the home fans who are perplexed by the loss of form from a team which picked up a record points haul in the Primera Liga last season.
As the clock ticked beyond the hour, Marcelo twice shot narrowly wide. Silva was given a vast standing ovation from the home crowd as he was substituted in the 64th minute for Edin Dzeko, who was booed as he entered the field. The Bosnian would change the game just four minutes later after controlling a pass from Toure to side foot past Casillas.
The 3,800 away fans danced in joy on the stadium's highest tiers and dreamed of victory but City's lead lasted just eight minutes and was undone when one of Marcelo's curling shots finally beating Hart from outside the area.
Kolarov's strike from an inswinging free kick saw the visitors again dream of victory, but Madrid were level again two minutes later when Benzema turned cleverly on the edge of the area before driving the ball to the left of Hart to equalise.
As the huge crowd urged them on to victory, Ronaldo unleashed the game's decisive strike, his low right-footed shot from the right too difficult for Hart.
Follow us @SprtNationalUAE