Napoli run riot at 10-man Inter
Earlier, Bojan, Pablo Osvaldo and Simplicio were on target as fourth-placed AS Roma beat Atalanta 3-1.
After an end-to-end start at Inter the game turned dramatically on an incident four minutes before the break when Joel Obi was handed a second yellow card for bundling over Christian Maggio on the edge of the box.
Julio Cesar saved Marek Hamsik's resulting penalty but defender Hugo Campagnaro followed up to give Napoli the lead.
Ranieri was sent off for remonstrating with the referee as the teams trooped off at half-time.
"He ruined a beautiful game," the Inter coach told Sky Sports. "He was not on his game. What he could get wrong, he did get wrong.
"The boys gave their all and should not have been punished in this way. I don't normally complain about these things but today was an exceptional occasion."
In a more subdued second period wing back Maggio added a second goal on 57 minutes, lifting the ball over Julio Cesar, before Hamsik slotted home the third with a quarter of an hour to go to seal Napoli's first victory at the San Siro in 17 years.
The hosts, without Wesley Sneijder and Diego Milito, edged the opening exchanges at the San Siro with Diego Forlan going closest to scoring after fizzing a low 25-metre drive just wide on 13 minutes.
Despite missing striker Edinson Cavani through injury, Napoli enjoyed plenty of possession in a refreshingly open start and Colombian left-back Juan Zuniga headed weakly wide with a back-post header after 19 minutes.
The home crowd then started to jeer when Campagnaro put Napoli in front.
The visitors made it 2-0 when Giuseppe Mascara played an innocuous ball over the top of the Inter defence for the energetic Maggio to outpace substitute Yuto Nagatomo and beat Julio Cesar.
With a disjointed Inter leaving huge gaps at the back, Hamsik ran on to Ezequiel Lavezzi's slide-rule pass to ensure Napoli ended a run of eight straight defeats at Inter.
Napoli coach Walter Mazzarri, who turned 50 on Saturday, thanked his players.
"It's a beautiful present the boys have given me," he said. "For the penalty I don't know if it was a mistake or not, I have to see the replay.
"But I do know Napoli played a great game and deserved to win. We've had decisions go against us so I hope there won't be too much said about it."
At the Stadio Olimpico, Roma resisted a second-half fightback from promoted Atalanta to earn Luis Enrique's side their second successive win.
Spanish striker Bojan opened the scoring on 20 minutes, grabbing his first goal in the Giallorossi shirt with a left-foot shot.
Argentine forward Pablo Osvaldo doubled the lead with a cool finish just after the half-hour as Roma dominated the opening period.
The second half was a different story after Argentine forward Germ