Manuel Pellegrini's side had already secured their place in the UEFA Champions League knockout stages but needed to win by a more convincing margin than 3-1 to top the group, and their chances looked to have been extinguished after a disastrous opening 12 minutes in which goals from Thomas Muller and Mario Gotze put Bayern 2-0 up.
However, City responded positively and reduced their arrears through David Silva after 28 minutes, before Aleksandar Kolarov equalised from the penalty spot in the 59th minute after James Milner had been brought down by Dante.
Milner fired in a terrific finish three minutes later and City held on to end Bayern's record-breaking run of 10 straight Champions League wins, but they could not grab the fourth goal required to overhaul the Germans as group winners.
Pellegrini had admitted in the build-up to the match that he was preparing for it with Saturday's Premier League home clash against table-toppers Arsenal also in mind, and his team selection reflected that.
The Blues' first XI showed seven changes from last weekend's draw at Southampton, with Joe Hart, Micah Richards, Joleon Lescott, Javi Garcia, Jesus Navas, Edin Dzeko and the fit-again Silva being brought into it and the likes of Vincent Kompany, Zabaleta, Sergio Aguero, Alvaro Negredo and Samir Nasri dropping out - the first four to the bench - as well as the suspended Yaya Toure.
For Bayern, meanwhile, there were just two alterations from their 7-0 win at Werder Bremen, and their potency was soon evident.
Hart, making only his second appearance in 10 City games, had already endured a nervy moment due to a miscued attempted backpass from Lescott when Muller put Bayern 1-0 up.
The forward chested down a lofted delivery from Dante, got the better of City's skipper-for-the-night Kolarov and fired past the England goalkeeper.
Hart got down to save a Dante header four minutes later, and then diverted the ball, struck by Franck Ribery, against the post, but it was not long before he was beaten again as Bayern kept up the heat.
City made a hash of trying to deal with a corner and the ball ricocheted via Mario Mandzukic's shot to the feet of Gotze, who converted from six yards out.
Richards limped off for Pablo Zabaleta soon after and there was further Bayern pressure to weather, with Ribery's shot being blocked and Hart denying Toni Kroos.
But then Fernandinho fired off-target at the other end and with City having settled down, Silva - back after six games out due to a calf problem - hooked in to make it 2-1, connecting with a Milner header from Navas' cross.
Navas put the ball into the side-netting within moments and it was a fairly even contest for the rest of the first half, although there were a couple of warnings from the hosts, with Hart having to come out to keep Gotze at bay and City's ex-Bayern man Martin Demichelis getting in the way of a Muller shot.
City made a solid opening to the second half and after Dzeko had called Manuel Neuer into action, Dante brought down Milner in the area and the penalty was awarded.
Kolarov made no mistake from the spot and then City were in front as Milner superbly swept in a Navas cross which former Blues defender Jerome Boateng attempted to hack away but completely missed.
City kept pushing and sloppiness from Dante allowed Negredo the opportunity to make it 4-2 with 11 minutes to go, but Neuer saved.