The midfielder went from hero to zero in the match, although his goal proved enough to earn the Rossoneri a result in the hunt for Champions League qualification
Walter Mazzarri's Scudetto contenders entered the battle for second place with a four-point advantage over their hosts, after the Milan giant's bid for direct qualification to the next edition of Europe's premier club competition stalled in the last round with a contentious 2-2 draw away to Fiorentina.
The Rossoneri wasted no time setting the tone for the encounter as Ignazio Abate forced several early openings down the right. One of the full-back's deliveries found Kevin-Prince Boateng lurking outside Napoli's area, where the Ghana international let fly with a shot that forced Morgan De Sanctis to make a smart intervention following a deflection off Paolo Cannavaro's heel.
Cristian Zapata failed to test the visitors' goalkeeper after heading over from Riccardo Montolivo's corner in the ninth minute, but the respite was not to last as Kevin Constant's deflected effort required a save, before the Guinean nearly turned provider when his lofted pass was side-footed wide by Boateng.
A succession of Napoli corners did not succeed in blunting their hosts' endeavour, and a neat set of interchages between Robinho and Boateng on the edge of the area in the 30th minute teed up Flamini for his left-footed finish, which the 29-year-old emphatically rifled low into the corner beyond De Sanctis' reach.
Proceedings had just sprung to life, with the set-back failing to break the Southerners' resolve when they found the equaliser just three minutes after going behind. Goran Pandev escaped Zapata's attention to pick up Hamsik's exquisite through-ball, slotting high into the back of the net to spark wild celebrations from Mazzarri and the Napoli bench.
It was now Milan's turn to weather the storm, and the San Siro faithful watched on in baited breath as Edinson Cavani effortlessly controlled a searching ball over the top before attempting to lob Christian Abbiati, the burly keeper showcasing his reflexes in the process of tipping the ball over as referee Gianluca Rocchi called time on an electric first half.
Flamini failed to trouble De Sanctis with an opportunistic attempt as the Milan giants began the second-half seeking to regain the initiative, but teenage striker M'Baye Niang wasted an opportunity by scooping a free-kick on the edge of the box well over the bar.
Hopes of re-taking the lead took a heavy blow when Flamini's high-footed challenge on Juan Zuniga prompted a scuffle on the byline in the 72nd minute though, leading to a straight red card being produced for the Frenchman. Allegri promptly responded by introducing Stephan El Shaarawy to provide additional impetus in the final third.
The match had already begin running out of steam though and, with neither side able to gain the ascendency despite Napoli's numerical advantage, action began to get bogged down in midfield. Several half-chances, penalty area altercations and Emanuele Calaio's scuffed golden opportunity to capture the lead for the Partenopei later, Rocchi called time on the spectacle.
Milan's 14th game unbeaten coincides with Napoli going within eight points within Juventus at the pinnacle of Serie A, with the Italian champions only due to play at Lazio on Monday.