Mattia Destro's brace either side of Luca Rossettini's first-half goal looked to have put the game to bed but Gonzalo Higuain scored two goals in the final three minutes of normal time to set up a tense finish.
However the hosts held on to move up to 15th while Napoli missed the opportunity to leapfrog Inter Milan at the top of the Serie A table.
Since Roberto Donadoni's reign, the Rossoblu were unbeaten in three before their 2-0 defeat at Torino last week and his side were on the front foot as they took the lead after 14 minutes.
Destro, who returned from a one-game suspension, beat the offside trap to get on the end of Amadou Diawara's lofted ball before slotting home.
Rossettini claimed the second seven minutes later when he headed in Franco Brienza's corner. The hosts looked to be in cruise control when Destro scored his fourth goal of the season after the break. The former Roma striker's scuffed effort swept past Pepe Reina on the hour mark.
But the Partenopei responded three minutes from time as Higuain poked home his 13th goal of the season before grabbing his second in the space of three minutes. The hosts would hold them at bay, however, as Maurizio Sarri's side lost just their second game in the Serie A this term.
Fiorentina assumed second place by trouncing Udinese 3-0 at the Stadio Artemio Franchi.
Napoli's defeat left them vulnerable to being leapfrogged by La Viola, who duly obliged thanks to goals from Milan Badelj, Josip Ilicic and Gonzalo Rodriguez.
Paulo Sousa's men are now one point behind leaders Inter. Their next league engagement sees them visit bitter rivals Juventus and victory there, coupled with a poor result for Inter at Udinese, would take the Tuscan side top.
Badelj's opener arrived in the 26th minute, the midfielder blasting Edenilson's poor clearance against the legs of team-mate Nikola Kalinic to wrong-foot Udinese goalkeeper Orestis Karnezis.
The Bianconeri almost equalised on the half-hour mark with Cyril Thereau heading against a post from a corner.
It was nip-and-tuck for a while after the break, at least until Fiorentina were gifted an opportunity to double their lead. Emmanuel Agyemang-Badu brought Kalinic down in the box and Ilicic gladly obliged from the penalty spot.
Mid-table Udinese, who had been targeting a third straight win having beaten Sampdoria and Chievo in recent weeks, knew their race was run in Florence and could do little about their hosts' final strike of the afternoon.
Full of confidence now that all three points were in the bag, Fiorentina piled bodies forward at an 86th-minute corner and it was defender Rodriguez who rose highest to nod the ball beyond Karnezis.
AC Milan's bid to muscle into the title race hit a snag as they were held to a goalless draw at Carpi.
The Rossoneri had won four of their last six matches to climb back into contention for European football but this stalemate at the Stadio Alberto Braglia proves they have a long way to go before restoring former glories.
Indeed promoted Carpi - now in double figures for the season - enjoyed the better chances of a balanced encounter, with former Milan striker Marco Borriello going closest to beating Gianluigi Donnarumma.
The 16-year-old Milan goalkeeper watched Borriello control Lorenzo Lollo's header forward before rifling the ball past a post in the 10th minute.
Carpi had the next opportunity. Lollo tried his luck from 20 metres out but Donnarumma flew across his goalmouth.
Sinisa Mihajlovic's men mounted a promising raid as half-time approached, with M'Baye Niang forcing Vid Belec to tip the ball over the crossbar for a corner.
When play resumed Borriello was soon setting up Kevin Lasagna for a one-on-one with Donnarumma that the Carpi striker wasted under little pressure.
Belec got gloves to Giacomo Bonaventura's free-kick in the 75th minute and, with five minutes remaining, the Biancorossi keeper repelled Alex's header and three separate scuffed attempts to score by Milan players.
The point earned moves Milan into a share of seventh place with Atalanta, but UEFA Europa League football is another three points away - and top spot nine points beyond their reach.
Sassuolo stunned Sampdoria 3-1 at the Marassi to move back into the race for a Europa League place.
Francesco Acerbi opened the scoring for the Neroverde with a deflected goal inside eight minutes. Sergio Floccari and teenager Lorenzo Pellegrini made the points safe before Ervin Zukanovic grabbed a consolation for Samp.
Ten-man Atalanta moved up to seventh place after a 3-0 home humbling of Palermo.
In-form striker German Denis grabbed the opener with Nicolo Cherubin and Marten de Roon rubbing salt in the Sicilian side's wounds. Atalanta's Giulio Migliaccio made a brief cameo from the bench before being sent off.
Luigi Delneri's reign as Hellas Verona boss began as his predecessor Andrea Mandorlini's ended - with a defeat.
Andrea Costa's strike proved enough to earn Empoli a 1-0 victory at the Stadio Marc'Antonio Bentegodi, condemning basement boys Hellas to their ninth loss of the season.
There was more bad news for Verona fans post-match as veteran striker Luca Toni, 38, announced his intention to retire at the end of a campaign which looks certain to end with relegation.
Elsewhere, Alberto Paloschi and Riccardo Meggiorini scored to boost Chievo to a 2-0 victory at Frosinone.