The reigning champions had raced into a two-goal lead through Thomas Muller and Mario Gotze, but strikes from David Silva, Aleksandar Kolarov and Milner secured a stunning win
The two teams were guaranteed to qualify, but that did not stop the Bavarians making a roaring start to the match; Thomas Muller latched onto Dante's long ball and slotted the ball past Joe Hart before Mario Gotze doubled the lead moments later.
But City responded through the returning David Silva, who scrambled the ball over the line on the half-hour mark, and then Aleksandar Kolarov levelled the scores from the penalty spot. Barely five minutes later, James Milner, who won the spot-kick, unleashed a thunderous drive that gave the visitors the victory.
Vincent Kompany, Sergio Aguero, Alvaro Negredo, Yaya Toure and Samir Nasri were all missing from a City XI that showed Pellegrini had one eye on Saturday's crunch Premier League clash against Arsenal, while Bayern were much closer to full strength.
The gulf in class was quickly apparent; City barely left their half in the opening stages and it was little surprise when Muller caught Kolarov napping to clinically convert Dante's raking pass.
Franck Ribery then struck the post following a botched Joleon Lescott clearance, before Gotze prodded home from close range to capitalise on another City defensive error, with the visitor's defence unable to clear a corner.
The visitors' nightmare start took another turn for the worse as Micah Richards hobbled out of the action with a suspected hamstring problem and was replaced by Pablo Zabaleta.
Pellegrini's men tentatively emerged from their early struggles and Silva reduced the arrears when Milner showed excellent endeavour to knock Jesus Navas' right-wing cross back across goal for a simple finish.
City proceeded to play their part in a more even contest shortly before the break, but Joe Hart was called upon to thwart Gotze in the 43rd minute before former Bayern defender Martin Demichelis salvaged a wretched individual half by producing a last-ditch tackle to deny Muller.
Edin Dzeko stung Manuel Neuer's palms in the 51st minute after Silva and Milner had linked nicely down the Bayern right. The same combination caught Bayern out again six minutes later and referee David Fernandez pointed to the spot as Dante clumsily sent Milner tumbling. Kolarov coolly converted.
And Milner, having had a hand in both the previous goals, continued a superb evening with a measured finish across Neuer from Navas' centre as Silva picked Bayern apart once more.
City then threw on Alvaro Negredo in place of his international colleague Silva and the bustling striker capitalised in an error from the clearly rattled Dante, leaving Neuer's outstretched boot to preserve Bayern's top spot in the group, though they were nevertheless denied an 11th straight Champions League win.