© AP Photos
The Uruguayan fired into the bottom corner despite a brave effort from Andrea Consigli, who got a hand to the ball.
A comedy of errors in defence gifted Atalanta an equaliser before the break when Paolo Cannavaro headed into his own net from close range.
Cavani restored Napoli's lead just after the interval when he hammered home after finding space inside the penalty area.
Once again Napoli failed to maintain their advantage as German Denis came back to haunt his former club with an equaliser 20 minutes from time.
With 10 minutes left Napoli surged up the other end to score a dramatic winning goal.
A sweeping move was finished off by Pandev, who showed a quick turn of pace to tuck away his first goal of 2013 at a crucial time.
Atalanta were unable to equalise for a third time as Walter Mazzarri's side held on to record a vital victory.