The visitors went into the game as huge underdogs, having failed to win since 25. Nov, a run of seven games that left them in the relegation zone.
Napoli now have one win in their last five league games, losing three, and have dropped to fifth place on 28 points, while Spezia's victory lifted them up to 16th on 14 points.
Napoli asserted their expected dominance in the first half as captain Lorenzo Insigne shot wide with just the goalkeeper to beat before Spezia's Ivan Provedel made important saves to keep the game goalless at halftime.
Petagna's introduction proved to be the catalyst for the home side's breakthrough, as the substitute stabbed in from close range five minutes after coming on.
But Spezia levelled 10 minutes later when Nzola converted a penalty after Fabian Ruiz collided with Pobega in the box.
The equaliser came against the run of play and the away side's hopes of clinging on were dealt a blow when Ismajli earned a second yellow card in the 78th minute.
But Vincenzo Italiano's side scored a stunning winner with nine minutes remaining when Nzola's dinked effort came off the foot of the post and Pobega got to the rebound first to finish.
It was a frustrating result for Gennaro Gattuso and his side, who had 27 shots to Spezia's eight and enjoyed 57% possession.