Matteo Politano put Napoli ahead from the penalty spot after Sergino Dest's clumsy foul on Khvicha Kvaratskhelia.
Olivier Giroud pulled Milan level in the 69th minute, but Giovanni Simeone headed home a winner in the 78th minute to ensure Napoli returned to the Serie A summit.
Milan had 22 shots to Napoli's nine, but Pioli says that is scant consolation after watching his side suffer a first league defeat of the campaign.
"I am not satisfied at all and neither should my players be," he said. "We only scored one goal, which isn't enough for all that we created.
"It's disappointing because nights can happen when the opponents play better, but in this case we really shouldn't have lost.
"I hope we will learn from this to be more clinical in front of goal because we did everything right except for errors and a lack of determination in both penalty areas.
"I could have said I was very happy because we played better than Napoli and created lots of chances, but seeing as we were the only side unbeaten in Europe's top five leagues for 22 matches – longer than Bayern Munich, Manchester City and Real Madrid – it's a shame to lose it with a performance like that.
"On Simeone's goal we had too many players attacking the man with the ball, forcing Messias to sit deeper, which freed up Mario Rui.
"It's difficult to blame our defensive movements when Napoli only really had that chance. I am more bitter about the lack of chances that we converted.
"We allowed very little to a side that usually creates and scores a lot of goals. It's true we are conceding too many at the moment and need to work on that, but my concern is more up front."
Milan, which dropped down to fifth with the defeat, travels to Empoli on 1 October after the international break.