The German giants also suffered their first defeat in major competition since coach Pep Guardiola took charge in June.
Bayern also fell to their first home defeat -- after 18 wins -- since losing 2-0 at home to Arsenal in last season's knock-out stages of the Champions League in March.
With both teams already through to the knock-out stages, City avenged October's 3-1 defeat to Bayern at the Etihad Stadium, but still finished second to the Germans in Group D with both teams on 15 points.
It had started ominously for City as Bayern produced a flawless opening 20 minutes to race into a 2-0 lead after 11 minutes.
Goals by Thomas Mueller and Mario Goetze left Bayern cruising before David Silva pulled one back for City as it finished 2-1 at the break.
Captain Aleksandar Kolarov then converted a penalty to pull level on 59 minutes before James Milner gave City a deserved lead three minutes later with a superb curling shot to complete the miraculous fight-back.
With a home game against Premier League leaders Arsenal on Saturday, City coach Manuel Pellegrini had decided to put first choice strike pairing Sergio Aguero and Alvaro Negrado on the bench.
City had needed to win at least 3-0 to wrestle top spot from Bayern and their hopes seemed to have evaporated in the opening minutes.
With barely two minutes gone Bayern winger Franck Ribery pressurised City goalkeeper Joe Hart into conceding a corner.
The first goal followed soon after when centre-back Dante's superb crossfield pass from inside the Bayern half found Mueller in behind the defence to drill his shot past Hart with five minutes gone.
With Bayern dominating possession and attacking in waves, the second followed on 11 minutes when Goetze fired home from close range after City fail to clear their lines from a Toni Kroos' corner.
The 21-year-old midfielder profited after Mario Mankiewicz's blocked shot fell into his path and it looked like it was game over for City.
Pellegrini responded with a change with Pablo Zabaleta on for Micah Richards.
The game's tempo dropped sharply after the second goal and City profited when Fernandinho fired wide before David Silva pulled a goal back on 28 minutes after some good work from Milner and Jesus Navas.
The goal awakened Bayern's attack and Hart did well to deny Goezte with the half-time whistle approaching, while City's former Bayern defender Martin Demichelis also blocked a Mueller shot.
City drew level after the break when Milner was pushed from behind by Dante following a strong run into the area and Neuer dived the wrong way as Kolarov fired home.
Bayern now had a fight on their hands and Milner put City ahead three minutes later when he curled his shot around Neuer and inside the far post to the delight of the travelling City fans in the sold-out 68,000 crowd.
This was only the second time Bayern have thrown away a two-goal lead in the Champions League having gone down 3-2 to AS Roma in November 2010.