Cristiano Ronaldo looked to have put the game beyond Napoli when he struck Juve's third goal just after the hour-mark following first-half goals from substitute Danilo, on his debut, and Gonzalo Higuain.
But in time added on, Napoli's Senegal defender Koulibaly turned the ball into his own net to gift Juve their second Serie A win of the season in front of boss Maurizio Sarri, who was watching from the stands following a bout of pneumonia.
Juve, who handed debuts to Danilo and Matthijs De Ligt, the latter in place of injured skipper Giorgio Chiellini, were first to threaten when Ronaldo's long-range effort was well saved by Napoli goalkeeper Alex Meret.
Napoli responded through Allan's fierce low shot from outside the area, which was brilliantly saved by Juventus goalkeeper Wojciech Szczesny before the home side struck twice in three minutes to seize control.
Danilo, who had replaced the injured Mattia De Sciglio a minute earlier, opened the scoring with his first touch, firing home from inside the area following a swift counter-attack and a Douglas Costa assist.
Juve made it 2-0 in the 19th minute. Napoli failed to clear the danger following a free-kick into the area and Higuain lashed the ball home his first goal of the season into the top corner.
Ronaldo headed wide on the half-hour mark and Sami Khedira's shot from outside the area crashed off the crossbar, while Lorenzo Insigne spurned a chance for Napoli just before half-time when he blazed off target following a corner.
Napoli started the second period on the front foot. Piotr Zielinski forced Szczesny into another good save, Dries Mertens fired just wide and Di Lorenzo's header flew the wrong side of a post.
Juventus midfielder Blaise Matuidi and Mertens both had decent attempts well saved before Ronaldo appeared to have settled the contest in the 62nd minute.
The Portuguese latched on to another Douglas Costa assist and buried his shot into the bottom corner for his first goal of the season.
But Napoli struck twice in as many minutes to turn the game on its head.
Manolas headed home Mario Rui's ball into the box and in the 68th minute Lozano lashed in Napoli's second after being picked out by Zielinski in the area.
Douglas Costa and Napoli's Fabian Ruiz both went close to adding to the scoreline – the former's effort hitting the crossbar – before Di Lorenzo's angled drive from the left side of the six-yard box, following Jose Callejon's cross, found the bottom corner.
Juve's Paulo Dybala then pulled his shot wide and just as the game appeared to be heading for a draw, Koulibaly made a hash of his attempted clearance from a free-kick in the second minute of added time and turned the ball into his own net.