Former Inter midfielder Muntari gave Milan the lead inside 30 seconds, but Pirlo -- who spent a decade at the San Siro -- equalized after 15 minutes with a set-piece that goalkeeper Christian Abbiati could only deflect into the net.

Substitute Sebastian Giovinco put Juve ahead in the 69th minute from Arturo Vidal's pass, soon after his arrival on the pitch, and then Mexes' moment of madness was to prove vital for Milan as Chiellini immediately capitalized.

The defeat left the seven-time European champion languishing in 12th place, some 13 points adrift of Roma.

Napoli, like Juve, has six wins and a draw from seven matches, continuing new coach Rafael Benitez's fine start.

Former Real Madrid striker Gonzalo Higuain was again missing due to injury, but the Neapolitans had too much firepower for Livorno.

Striker Goran Pandez followed up last weekend's double against Genoa with another goal, while midfielder Gokhan Inler's speculative long-range shot went through keeper Francesco Bardi before Jose Callejon and Marek Hamsik netted in the second half.