Aguero struck 20 minutes from time to give his side a 3-2 lead. Leroy Sané broke from his own half in a counter attack but the German was stopped. The ball fell to Aguero who carried it on and swept past Pepe Reina in the Napoli goal.
Raheem Sterling sealed the victory with his 10th goal of the season in stoppage time.
The win confirmed City’s progress to the last 16 knockout stages and condemned Napoli to their third defeat of their Champions League campaign.
While the Italians have been all conquering in Serie A – with 10 wins and a draw in their 11 games – they have twice lost to City and Shaktar Donetsk in the Champions League.
Napoli’s woes will be of little concern to City who advance to the knockout stages for the fifth consecutive year.
"What Aguero has achieved has made him a legend,” said City boss Pep Guardiola. “He's gone down in history, so I would tell him to enjoy."
Aguero joined Manchester City from Atletico Madrid in 2011. And after moving one ahead of the 1930’s striker Eric Brook, the Argentine paid tribute to his teammates and fans.
"I'm very happy for this moment and happy because the team help support me and the fans. I'll enjoy this moment because it only happens once.”
City needed one point to book their spot in the last 16 but gained their victory after falling behind to Lorenzo Insigne’s 21st minute goal.
"They completely destroyed us in the first 20 minutes," said Guardiola. "We suffered a lot but our players showed personality.
"The point is how in the bad moments the team react and they did really well. The level of football for a spectator was just amazing all I could say was 'wow'."
Nicolas Otamendi drew City level with a header after 35 minutes. John Stones edged the visitors ahead three minutes after the break.
Jorginho converted a penalty to make it 2-2 after 62 minutes. But seven minutes later, City and Aguero were ahead.
"Napoli is a good team," added Aguero. "Playing away in the Champions League is difficult.
"I am very happy to win and qualify. We must keep going in the same way in every game, playing the same way. It is a long season and although we are good now, we must continue the same way."