However, Bayern still won Group D with City finishing in second place.
Prolific Ronaldo took his tally to nine for the campaign in Real's 2-0 win at FC Copenhagen, with the nine-times champions also setting an all-time record in European competitions by netting in 31 successive matches.
Ronaldo, in his first game back since sustaining a muscle strain on November 23, scored with a simple close-range finish three minutes after the break, Real's second after Luka Modric's delightful opener.
Bayern manager Pep Guardiola suffered only his second loss in 25 matches since taking over from Jupp Heynckes.
"When you go 2-0 ahead, you have to play better than that," Bayern captain Philipp Lahm told Sky Sports Deutschland. "But we can live with the defeat, we are still group winners."
A heavy loss looked on the cards for City when slack defending allowed Thomas Mueller and Mario Goetze to fire the German side 2-0 ahead after 12 minutes.
David Silva started the comeback with a simple finish to reduce the deficit by the break and James Milner won a penalty, converted by Aleksandar Kolarov, and side-footed the winner in a three-minute second-half spell.
"We wanted revenge for the first game (Bayern won 3-1) and to show it was not that different between Bayern and our team," said City manager Manuel Pellegrini.
"To win here and score three goals without Vincent Kompany, Yaya Toure, Alvaro Negredo and Sergio Aguero shows we have a very good squad also, so it's a very important victory."
Leverkusen's 1-0 win at Real Sociedad put them through as runners-up behind Manchester United in Group A.
The Bundesliga side's victory, earned by Oemer Toprak's second-half goal, lifted them above Shakhtar Donetsk into second after the Ukrainians lost 1-0 at United.
Javier Saviola scored twice as Olympiakos pipped Benfica to second spot in Group C by beating visitors Anderlecht 3-1.
In an extraordinary match, the Belgians finished with eight men after the Greeks scored one penalty and had two saved by keeper Silvia Proto, including one from Saviola.
The Anderlecht stopper spoiled his night by getting sent off in stoppage-time, joining Cheikhou Kouyate and Fabrice N'Sakala in seeing red.
Benfica won 2-1 against group winners Paris St Germain, who rested top scorer Zlatan Ibrahimovic, but drop into the Europa League despite finishing on 10 points along with Olympiakos who enjoyed head-to-head superiority over the Lisbon club.
Galatasaray or Juventus will join Group B winners Real Madrid in the knockout stage when they return to finish their match in Istanbul on Wednesday.
The players were taken off the Ali Sami Yen stadium pitch by Portuguese referee Pedro Proenca after 32 minutes following heavy snowfall with the score at 0-0.
UEFA said in a statement the match "will continue on Wednesday from 1400 CET (1300 GMT)".
After losing two successive Premier League games at Old Trafford, Manchester United stopped the rot thanks to a second-half Phil Jones goal at Old Trafford which sent Shakhtar into the Europa League.
"We wanted to top the group and we have. The win helps us, improves our form," said manager David Moyes. "A club like Manchester United has to be trying to win the trophy."
Viktoria Plzen scored two late goals to beat CSKA Moscow 2-1 to secure third place and a Europa League spot in Group D.
Substitute Tomas Wagner rifled home the winner in the 90th minute to send Plzen into the Europa League at the expense of CSKA who finished with nine men after Alan Dragoev and Pontus Wernbloom were dismissed late on.