Elsewhere, Paris Saint-Germain marked its new big-spending era with an emphatic 4-1 win over Dynamo Kiev.
Madrid forward Cristiano Ronaldo beat goalkeeper Joe Hart in the 90th minute to cap a dramatic comeback as the nine-time Champions League winners twice came from behind for a morale-boosting victory over the English champions following a week of domestic disarray.
While Madrid showed its pedigree as nine-time champion against its rich and ambitious opponent, AC Milan couldn't seem to use one of its favourite competitions to shake off its early season troubles as it was held to a 0-0 draw at home to Anderlecht.
Also, Robert Lewandowski scored late as Borussia Dortmund kept pace with Madrid in the tough Group D with a 1-0 win over Ajax.
Arsenal shook off its poor away form in the competition to win 2-1 at French champion Montpellier, while Schalke also opened Group A with a 2-1 road win at Olympiakos.
FC Porto won 2-0 at Dinamo Zagreb while Malaga thrashed Zenit St Petersburg 3-0 in its competition debut.
City hoped to get off on the right foot after missing out on the knockout stages last season in the matchup between the champions of Spain and England. The big-spending Premier League club certainly had its chance only to come undone against a dogged opponent desperate for a victory.
"The most important thing was to win and we did that. The team is good, the fans are good, and I'm good," said Ronaldo, who returned to the Santiago Bernabeu for the first time since saying he felt "sad" at Real. "It was a crazy game".
Ronaldo's winner capped a frantic finale after City had done well to soak up Madrid's pressure in the first half before twice taking the lead in the second.
"It is difficult not because we lost – we can lose against a side like Real Madrid – but because with four minutes to go it was 2-1," City manager Roberto Mancini said.
Madrid's weakness on set pieces again proved costly as Aleksandar Kolarov curled home a freekick in the 85th minute to re-establish the advantage after Marcelo had cancelled out Edin Dzeko's 68th-minute opener as City's substitutes performed.
Madrid came roaring back. Substitute Karim Benzema turned to squeeze home an 87th-minute equaliser past Hart, before Ronaldo capped the rally as the hosts shook off the criticism following a poor domestic start.
Ronaldo, who refused to celebrate when scoring in his last home game, didn't hesitate to do so this time and neither did coach José Mourinho.
"I recovered my team, now I just hope I don't lose it," Mourinho said.
Lewandowski controlled the ball in the penalty area before hammering home a shot with three minutes remaining to reward Dortmund's late dominance and get its hopes of advancing rolling in the toughest group of the competition.
Zlatan Ibrahimovic became the first player to score for six different clubs in the competition. PSG attacked with gusto from the outset, eight years after its last appearance in the competition, and the convincing win confirmed PSG's status as Group A favourite ahead of Porto.
"It's always important to win your first game in the Champions League," PSG coach Carlo Ancelotti said. "To play the way we did tonight can only be good for our confidence."
Ibrahimovic, who previously scored for Ajax, Juventus, Inter Milan, Barcelona and Milan, netted from the penalty spot in the 19th for his sixth goal from six matches.
Brazil defenders Thiago Silva and Alex profited from terrible marking to put the home side 3-0 ahead after little more than 30 minutes, with Javier Pastore answering Miguel Veloso's 87th-minute consolation goal.
Seven-time champions Milan is still searching for a positive result after its dismal start since Ibrahimovic's exit. The Serie A club failed to rebound from losing its first two home games for the first time in 82 years.
An error-strewn performance saw the Italian club's players jeered off the pitch by the more than half-empty San Siro.
"[The players] have to find a bit more confidence in themselves," Milan coach Massimiliano Allegri said.
Twenty-year-old Francisco "Isco" Alarcon scored twice and veteran striker Javier Saviola netted as Malaga went top of Group C with a rout in its Champions League debut.
Malaga, expected to struggle after heavy investment was cut off and players sold, instead dominated Zenit at its Rosaleda Stadium as the Russian club's offseason signing Hulk failed to lift it to victory.
"The team has been through a rough time, but that is what I am most proud of, that the team has seen its way through it," Malaga coach Manuel Pellegrini said.
Elsewhere, Lucho Gonzales and Steven Defour scored late in each half as Porto secured its 150th European victory against Dinamo Zagreb, which has lost seven straight in the Champions League.
Lukas Podolski and Gervinho scored as Arsenal came back from Younes Belhanda's ninth-minute penalty within 11 minutes for a positive result for a club that had lost eight of its past 11 away games in the tournament. Arsenal's coach Arsene Wenger watched from the stands as he served the first game of a touchline ban.
Benedikt Hoewedes and Klaas-Jan Huntelaar scored as Schalke ended Olympiakos' 10-year unbeaten run against German opponents on Greek soil in the Champions League. Djamel Abdoun leveled for Olympiakos in the 68th before Germany striker Huntelaar equalised one minute later. – Sapa-AP