Wesley Sneijder added a third deep into injury time in a scoreline that flattered the visitors, who were poor for most of the match and should have been reduced to 10 men with the score still goalless.
Morocco midfielder Kharja, signed from Genoa in the January transfer window, finished sweetly on 70 minutes after a neat exchange of passes with Samuel Eto’o, a rare moment of quality in a poor game at Stadio San Nicola.
In the third minute of stoppage time Pazzini drilled a second in off Bari keeper Jean-Francois Gillet, while Sneijder’s late third added a sheen to a fortuitous win that puts them third, seven points off leaders Milan with a game in hand.
Before Inter pulled away, Bari had several good opportunities but were foiled by poor finishing and some good goalkeeping from Julio Cesar.
Inter were also extremely fortunate not to play the last half hour a man light after Cristian Chivu - who will face a retrospective multi-game ban - punched Marco Rossi square in the face, from behind, with the officials looking the other way after the ball had gone.
The Romania defender will be dealt a severe punishment but that will do struggling Bari no good, as until then they had been the better side and will feel victory would have been possible with a numerical advantage.
Bari started well but that was largely due to Inter’s inactivity, with the little joy there was in the opening 45 minutes occurring before the half-hour mark.
Inter’s sluggish performance was surprising given their triple-pronged attack: although Sneijder returned to the bench after almost two months injured, Pazzini was flanked by Eto’o and Diego Milito but none of the three tested Bari’s Belgian keeper Gillet before the break.
With the home side starting on the front foot while Inter sat distressingly deep, Sergio Almiron’s excellent free-kick drew an equally smart save from Julio Cesar, while Simone Bentivoglio bounced a low finish wide after good build-up play from his team-mates.
The Bari midfielder was later booked for a dive in the box, while the best Inter could do was a couple of surging runs from Maicon that yielded poor crosses and finishing, and a header from Ranocchia at a corner, sent straight into the arms of Gillet.
That was on 26 minutes and, until the referee blew without a second of injury-time, there was quite literally nothing of interest from either side.
There was more to write home about early in the second half, as Eto’o combined with Milito before the Cameroonian’s finish was blocked by Rossi, but down the other end Ranocchia was struggling, his touch poor and balance off when he fell over in his box, unpunished by Bari.
Maicon got away with a possible handball in the area before Chivu’s assault on 59 minutes.
After an Inter set-piece was cleared Rossi, moving forward with the ball, was taken clean out by a cowardly jab from Chivu, left with a black eye and righteous anger as the Romanian scuttled back to his own half to seek refuge behind Julio Cesar.
As it stood Chivu escaped scot-free, and soon afterwards Kharja pounced, helped by a good substitution from coach Leonardo as Inter went from an ineffectual 4-3-3 to a more traditional front two.
That substitution - taking off the poor Milito for the returning Sneijder, who had been out for two months - gave the visitors more structure and a better handle on possession.
It also shunted Eto’o into a central position, from which he played a one-two with Kharja, whose finish was quite superb from left to bottom right.
Bari were forced to crank the tempo up, as Julio Cesar denied Alessandro Gazzi a superb left-foot volley while Ranocchia finally proved his worth with a timely intervention after Massimo Donati nearly sent Erik Huseklepp clean through.
Gazzi had another half-chance, firing weakly at Julio Cesar after a smart turn, but just as Bari looked set to complete a comeback Inter put the tie to bed when Almiron gave the ball away upfield, Thiago Motta releasing Pazzini whose finish went through the culpable Gillet.
That broke Bari and while the third goal was actually rather good - Kharja chesting Javier Zanetti’s ball down for Sneijder to finish low into the bottom right - memories of the evening will focus around Chivu’s assault and the subsequent comeback.