The visitors survived a barrage and then struck late to make the most of the slips by the two Milan clubs who both drew on Saturday.
The victory lifts Atalanta onto 56 points, level with AC Milan who occupy the fourth and final Champions League places.
The home loss at a less than full Stadio San Paolo followed Napoli's tame submission to Arsenal in the quarterfinals of the Europa League last Thursday.
For Napoli, the season effectively ended on Saturday when Juventus clinched an eighth straight Italian title. That meant the best Napoli could hope for was to serve as bridesmaids again and finish as runners up for the fourth time in seven seasons.
Where last season, under Maurizio Sarri, they finished only four points behind Juve, Monday's defeat leaves them 20 points behind with five games to go, though they still lead third-place Inter Milan by six points.
Victory would all but have ensured qualification for the Champions League and, while the home fans held up a banner demanding the return of Sarri, now at Chelsea, Carlo Ancelotti's teams created enough chances to have the game won by the hour mark.
Dries Mertens put Napoli ahead after 28 minutes touching in cross from French fullback Kevin Malcuit.
Napoli had chances to increase the lead.
Belgian Mertens could have had a hat-trick.
Arkadiusz Milik came closest, clipping the ball over diving Atalanta goalkeeper Pierluigi Gollini in the 50th minute but he was denied by veteran defender Andrea Masiello, who slid back to scoop the ball off the line.
Atalanta made the most of their escapes in the 69th minute.
Hans Hateboer reached the byline with time and space to pick his pass. The Dutchman rolled the ball to the near post as Duvan Zapata jogged between stationary defenders to side-foot the ball under goalie David Ospina.
The goal was the Zapata's 26th in all competitions this season breaking the Atalanta club record set by Italy legend Filippo Inzaghi in 1997. It was also the Colombian's 21st league goal of the season, leaving him one behind Sampdoria's Fabio Quagliarella who leads the Italian scoring charts.
Zapata also set up the winner with 10 minutes to play. He weaved through the penalty area before wrong-footing the Napoli defence with a back heel to Mario Pasalic who was able to pick his spot from 10 metres.