Edinson Cavani had twice put the hosts in front at Stadio San Paolo, with his first coming after just four minutes from the penalty spot.
A Paolo Cannavaro own goal levelled the contest just after the half hour mark, as did German Denis eight minutes after Cavani struck again in the 65th minute.
But Pandev’s goal eight minutes from the end put the Partenopei ahead for the third and conclusive time.
Cavani has scored 20 Serie A goals this season while Balotelli has scored seven in six appearances for Milan since his move from Manchester City.
Napoli, who have 56 points, are nine behind leaders Juventus and two ahead of Milan.
Fiorentina also led three times en route to a thrilling 3-2 victory over 10-man Genoa at Stadio Artemio Franchi which keeps them secure in fourth spot.
Alberto Aquilani’s first-half opener was cancelled out on 58 minutes by Daniele Portanova, only for Juan Cuadrado to restore the home side’s lead four minutes later.
Luca Antonelli levelled for the visitors once again before a second yellow card for Andrea Bertolacci and Mattia Cassani’s own goal ensured a miserable conclusion to the contest for Genoa.
Chievo struck twice in the closing stages to win away at Pescara 2-0, while Cagliari battled to a 0-0 stalemate at Siena.
Pescara were close to picking up only their second point in 10 games until Adrian Stoian scored with a curling effort for Chievo in the 86th minute and Cyril Thereau added another in stoppage time.