Marek Hamsik [ Images ] gave hosts Napoli an early lead 10 minutes into the game before Paolo Cannavaro and a Davide Astori own goal made it 3-0 as they galloped towards a fifth straight league win.
Cagliari's Joaquin Larrivey pulled one back with the first goal of an ultimately futile hat-trick as Ezequiel Lavezzi, Walter Gargano and Christian Maggio netted for Napoli in the second half.
Inter's Walter Samuel and Diego Milito scored in the 87th and 90th minutes respectively to give Ranieri's beleaguered side some respite given their last win in all competitions was against Lazio on January 22.
The victory moved Inter up to sixth with 40 points, two more than AS Roma, who play at Palermo on Saturday.
Both Napoli and Inter were playing on Friday to give them extra time to prepare for next week's Champions League [ Images ] last-16 second legs against Chelsea [ Images ] and Olympique Marseille [ Images ]
"Many of us scored tonight, and that is very important," Hamsik said. "Resting before the Champions League match against Chelsea will do us good."
League leaders AC Milan [ Images ], who top Serie A with 54 points, host third-bottom Lecce on Sunday while Juventus [ Images ], who trail Milan by two points, play at Genoa. Third-placed Lazio host Bologna and Udinese travels to Novara in late Sunday kickoffs.