The Reds were probing early on and passing the ball around the Napoli box but they could not find the penetrative pass.
Liverpool manager Jürgen Klopp was forced into an early substitution in the 19th minute as midfielder Naby Keita succumbed to injury and was replaced by Jordan Henderson.
Polish striker Arkadiusz Milik almost snatched the lead for the Italian side in the 33rd minute after turning well on the edge of the box before unleashing a powerful strike that was punched away by Liverpool shot-stopper Alisson.
Milik had another opportunity for Napoli five minutes after the break with a low strike from just outside the box but Alisson came out tops once again as the tempo was increased.
The Italian side were putting Liverpool under a lot pressure towards the 65th minute, looking seize their moments.
With 15 minutes to go, Jose Callejon came close to breaking the deadlock for Ancelotti’s men after collecting a cross at the back post but his strike was cleared off the line by Joe Gomez.
Klopp’s troops were not clicking going forward and were in danger of losing all the three points as Napoli kept on piling the pressure.
Dries Mertens almost punished Liverpool eight minutes before time getting past two defenders and unleashed a strike that came off the crossbar.
Lorenzo Insigne grabbed the winner for the hosts in the last minute of regulation time following consistent pressure from Napoil to snatch all the three points.
Ancelotti’s charges now occupy pole position in Group C with four points, while Liverpool are second, level on three points with Paris Saint-Germain who are third.