The Premier League leaders will now have to win their final game against group winners Bayern Munich and rely on a favour from pointless Villarreal against Napoli to progress.
The night in Naples was another learning curve for a side who may be dominant domestically, but are still off the pace at elite European level.
City had several chances in an eventful game, but Marek Hamsik also hit the post for the hosts, who dominated for long spells.
Cavani, Hamsik and Ezequiel Lavezzi — all of whom have been linked with City — were a handful all night in an imposing atmosphere.
The level of hostility facing City in the vast arena was apparent long before kick-off and there was little let-up in the noise throughout the game.
The huge crowd were not only boisterous, but had a seemingly large supply of fireworks and ear-piercing whistles greeted every spell of City possession.
City supporters were greatly outnumbered, but did their best to contribute to the atmosphere by setting off a number of firecrackers themselves.
City boss Roberto Mancini started with Edin Dzeko up front alongside Balotelli with Sergio Aguero on the bench.
As is customary, he rotated his full-backs, meaning there was no place for in-form Micah Richards on the right as Pablo Zabaleta came in.
Aleksandar Kolarov and David Silva were the other men to return and both were prominent as City probed.
Their first real opportunity saw Yaya Toure fire over before Balotelli bent a long-range effort wide.
Napoli hit back on the break and went close as Hamsik headed straight at Joe Hart from a Lavezzi cross.
Encouraged, Napoli then took charge with Lavezzi shooting wide after neat interplay with Cavani on the edge of the box.
Lavezzi got on the end of a cross from Andrea Dossena, but his volley was deflected wide.
Hart was then extended as Gokhan Inler forced him to palm over from long range, but City were undone from the resulting 19th-minute corner.
Cavani met Lavezzi's set-piece with a glancing header and the ball found a way past Hart at his near post.
It took some time for City to regain a measure of possession after falling behind but one steady move ended with Silva screwing a shot well wide.
City pressed again and levelled after 32 minutes when a poor clearance from Paolo Cannavaro went straight to Silva, who fired straight at Morgan De Sanctis. The goalkeeper parried but only as far as Balotelli, who gratefully tapped in from close range.
Kolarov broke into the area as City threatened a second just before the break but shot straight at De Sanctis.
The hard work to get back into the game was undone four minutes into the second half as Napoli regained the lead.
The visitors were caught out down their right as Dossena got behind Zabaleta to pull back for Cavani in front of goal.
The Uruguayan made no mistake as he sidefooted home his second with precision, although Hart could arguably have done better.
City came under further siege as Joleon Lescott blocked a shot from Hamsik and the Slovakian headed the rebound over. Inler put another attempt wide.
Silva tried to stir a response but badly miscued another shot.
Kolarov then teed up Balotelli at the end of a good move, but the City striker could not make firm contact in front of goal.
City were fortunate not to concede a third when Hamsik weaved his way into the box and struck the base of the post with a powerful shot.
Maggio then went through on goal as City were exposed again but Hart came out to smother the ball.
Yet City were not downhearted and Balotelli headed another good chance over from a cross from substitute Samir Nasri.
Silva forced another save from De Sanctis as City pushed for a late equaliser but Napoli held on.
If you have a complaint about the editorial content of the Belfast Telegraph or Sunday Life then contact the Editor here. If you are not satisfied with the response provided then you can contact the Independent Press Standards Organisation here
COMMENT RULES: Comments that are judged to be defamatory, abusive or in bad taste are not acceptable and contributors who consistently fall below certain criteria will be permanently blacklisted. The moderator will not enter into debate with individual contributors and the moderator’s decision is final. It is Belfast Telegraph policy to close comments on court cases, tribunals and active legal investigations. We may also close comments on articles which are being targeted for abuse. Problems with commenting? firstname.lastname@example.org