Cavani scores twice to leave City in strife
Napoli moved up to second place in Group A with eight points, one ahead of City, with one match each to play.
With leaders Bayern Munich already into the knockout stages after a 3-1 win over Villarreal, Napoli will also qualify if they win at pointless Villarreal on December 7 while City must beat Bayern and hope for the best.
Mario Balotelli, suffering from a bout of sickness according to coach Roberto Mancini, replied for City in between Cavani's goals but missed a couple of chances to equalise in a tense finale.
His frustration boiled over in the second half when he got a yellow card for arguing with the referee.
City enjoyed abundant possession and created plenty of openings but struggled to cope with a passionate San Paolo crowd and opponents who played on the break to great effect.
Napoli's attacking trio of Marek Hamsik, Ezequiel Lavezzi and Cavani looked dangerous every time they went forward, slicing holes in the City defence.
On paper, it had looked a mismatch between the unbeaten Premier League leaders and a side who are a modest seventh in Serie A.
City have spent five or six times more on their team than the Serie A club, according to Napoli President Aurelio Di Laurentiis.
"At the start I was worried," said Napoli coach Walter Mazzarri. "They looked strong, confident, I didn't think we would win, I thought it was a risky match, but the more the match was progressing, the team grew in confidence and the more I felt we could do it."
City began confidently but Napoli looked dangerous with every attack. Hamsik headed straight at Joe Hart from Lavezzi's cross, then Lavezzi himself fired wide after a one-two with Cavani.
The Uruguayan, struggling to repeat last season's prolific scoring this term, gave Napoli the lead in the 18th minute when he flicked on a corner and the ball deflected off two City players into the net.
Almost immediately, Cavani struck the side-netting following another quick break but the Napoli storm then blew itself out and City levelled in the 33rd minute.
Edin Dzeko crossed, Salvatore Aronica sent a dreadful clearance straight to David Silva in the penalty area and, although his angled shot was saved by Morgan De Sanctis, Balotelli was on hand to snap up the rebound.
City appeared to be on top but it was Napoli who regained the lead four minutes after the restart.
Lavezzi worked an opening for Andrea Dossena on the left and he pulled the ball back into the middle for Cavani to side-foot home.
The Italian side fell back into defence and frustrated City but were always dangerous on the break. Lavezzi forced a superb save from Hart after slipping his marker, then Hamsik hit the post.
Napoli were forced to defend desperately in a gripping final 15 minutes. De Sanctis saved a clever Balotelli volley and stopped another awkward shot from the Italian following a corner.