City looked to be heading to defeat against Bayern until Aguero popped up with two goals in the last five minutes to complete his hat-trick and turn the game on its head.
The home side had got off to the perfect start when Medhi Benatia was sent off after 20 minutes for bringing down Aguero for a penalty, with the Argentine picking himself up to score from the spot.
However, Bayern stunned City as two goals before half-time from Xabi Alonso and Robert Lewandowski turned the game in the German side’s favour.
City huffed and puffed in the second half, but Aguero came to their rescue with two deadly finishes to earn them a famous victory and a win against Roma in their final Group E game will see them progress to the knockout stages, so long as Bayern do not lose to CSKA Moscow.
After a bright start from City, Bayern created the first noteworthy chance of the game on nine minutes when Arjen Robben lofted a ball into the box and Sebastian Rode latched on to it to fire a shot goalwards, but Joe Hart stood up big to keep out the effort with his legs.
City won a penalty on 20 minutes when Aguero got on the wrong side of Benatia to latch onto Frank Lampard’s pass and the Bayern defender brought the striker down inside the box to concede the spot-kick, referee Pavel Kralovec showing a straight red card to the defender.
Aguero kept his cool from the spot to fire into the corner past Manuel Neuer for his 15th goal of the season and give City the advantage.
Pep Guardiola decided to shuffle his pack after losing Benatia, bringing on Dante for Rode to shore up his backline, but despite their numerical disadvantage Bayern still looked dangerous.
They drew level five minutes before the break when Xabi Alonso curled home a free-kick from the edge of the box after Eliaquim Mangala brought down Lewandowski. Alonso appeared to catch Hart by surprise as he rolled the ball low rather than over the wall and the ball trickled into the bottom corner past the stranded goalkeeper.
Things got even worse for City on the stroke of half-time as Lewandowski outmuscled Bacary Sagna to get on the end of Jerome Boateng’s cross, the ball coming off his shoulder and looping over Hart to give Bayern an unlikely lead.
Bayern picked up where they left off at the start of the second half and went close straight after the break when Franck Ribery picked out Alonso on the edge of the box, but the midfielder looped his shot over the top.
Jesus Navas forced Neuer into a save on 50 minutes when he burst down the right and drilled in a shot which the Bayern keeper turned behind.
City continued to push and probe for an equaliser and Lampard tried his luck from 25 yards with a fierce shot which Neuer tipped over the crossbar.
The home side looked to be running out of ideas until five minutes from time when Alonso’s poor pass was intercepted by Jovetic and the ball fell to Aguero. He raced clear of the Bayern defence before slotting his shot into the bottom corner past Neuer.
There was still time for City to grab a winner, as a minute into injury-time Aguero capitalised on a mistake by former City defender Boateng to go clear on goal, keeping his cool to fire past Neuer and spark wild scenes among the home fans and keep alive City’s Champions League hopes.