© AP Photos
The Uruguayan striker volleyed over soon after, before his spectacular overhead kick missed the target once again.
However, Napoli restored parity five minutes into the second half when Davide Astori inadvertently put the ball into his own net.
Cavani came close minutes later with a left-footed attempt from the left side of the box after latching on to Pandev's pass, but was thwarted by Michael Agazzi in the Cagliari goal.
Pandev himself saw his shot saved just after the hour mark, and minutes later Paolo Cannavaro was foiled by Agazzi.
However, the Cagliari goalkeeper failed to do anything when Cavani scored Napoli's second goal of the afternoon from close range following a corner from Christian Maggio.
Marco Sau shot home from outside the box in the 71st minute to make it 2-2, but there was yet more drama to come at the Stadio San Paolo in Naples, as Lorenzo Insigne fired in the winner from outside the box in the fourth minute of injury time.