The Slovak's 104th goal for Napoli pulled him level with former striker Edinson Cavani's tally for the Italians.
Inter travelled to Naples looking to continue their strong start under new coach Stefano Pioli, who started his spell in charge with a 2-2 derby draw at AC Milan and then a 4-2 win over Fiorentina at the weekend.
But Napoli were desperate to make up for dropping points in a 1-1 draw with Sassuolo, and were soon on their way to a morale-boosting win after hitting two quick-fire goals in the opening six minutes.
A great Napoli attacking move saw Jose Callejon knock down Hamsik's pass for Piotr Zielinski, who fired a low volley from 12 yards past Samir Handanovic and into the far bottom corner after just two minutes.
Inter were stunned only four minutes later when Hamsik beat the offside trap on his way to a through ball and fired an unstoppable angled drive under the Handanovic.
The Slovak's 104th goal for Napoli pulled him level with former striker Edinson Cavani's tally for the Italians, and put him well on the way to beating Maradona's club record.
"I'm happy, it's something positive for me. Now, it's full steam ahead to try and reach first place," he told Sport Mediaset as he targetted Maradona's mark.
Inter emerged in determined fashion after half-time, but all hopes of launching a fightback were kept in check by Lorenzo Insigne's 51st minute strike for the hosts.
Napoli moved up to provisional sixth place at five points behind leaders Juventus, who, despite a raft of injuries, host Atalanta on Saturday looking to avoid their second successive slip up after last week's 3-1 loss at Genoa.
Roma, in second at four points adrift, are away to Lazio in the capital derby on Sunday, when AC Milan, in third also at four points behind, host Crotone.
If Juve, or any other top five sides slip up, Napoli's win will have extra value and Hamsik added: "We're happy to be back to winning ways.
"We had an amazing start, it was important to get off the mark quickly tonight.
"It doesn't matter who scores the goals here, and it's also positive that we didn't concede any."
Inter's first Serie A defeat under Pioli leaves them in ninth place at 12 points behind Juve, but at risk of dropping further behind their rivals for a place in Europe next season.
"Conceding two quick goals like that left us with a lot of work," said Pioli.
"Tonight we found it more difficult than in previous games, but Napoli are a well-organised side with top players."