Police said assailants riding on at least four motorcycles opened fire at car carrying Amanullah Niazi, deputy superintendent of the Karachi Central Prison, on Thursday, killing him, two bodyguards and two passersby.
The attack took place on a busy street in a southern district of the port city, a senior police official said.
Sanaullah Abbasi, a police official said: "It appears to be a targeted killing and I can only confirm that three policemen were killed and two were wounded."
But Dr Tariq Kamal Ayubi said Karachi's Civil hospital had received five bodies.
Panic gripped the neighbourhood where a nearby market for electronic goods closed immediately after the shooting, which caused traffic chaos and left people running for cover, the private Geo TV station reported.
No details were immediately available on the identities of the killers nor the motive for the attack.