City led through Alvaro Negredo before goals from Thomas Muller and Mario Mandzukic turned the game around.
After a quiet opening Bayern should have taken the lead in the 29th minute, with Javi Martinez taking Arjen Robben's far-post cross away from his better-placed defensive colleague Dante.
City immediately went close against the run of play when Stevan Jovetic shimmied inside onto his right foot and lashed just wide.
Negredo missed out from crosses by Samir Nasri and James Milner late in the first half, both attempted headers bobbling harmlessly off his shoulder.
Another, more convincing, header after half-time was saved but Negredo opened his City account on the hour when he beat Martinez and fired inside the far post.
The lead lasted only five minutes, though, as Muller tucked away a penalty after Pablo Zabaleta was penalised for handball. The decision appeared extremely harsh, with Zabaleta beaten to a header and the ball rebounding off his trailing arm out of his field of vision.
And Mandzukic then stooped to head in Muller's cross and make it 2-1, just beating fellow City defender Jerome Boateng to the chance.
Edin Dzeko forced a late reaction save from Manuel Neuer but Bayern held on to win.
In the earlier third-place play-off, AC Milan beat Sao Paulo 1-0 thanks to Kingsley Boateng's goal early in the second half.
The Ghanaian teenager finished coolly after being picked out by Urby Emanuelson's long ball.