MULTAN, Pakistan — Gunmen on Friday killed a Pakistani prosecutor who had been investigating the murder of former Prime Minister Benazir Bhutto and the 2008 Mumbai attacks.

Assailants opened fire on the prosecutor, Chaudhry Zulfikar Ali, as he drove to work from his home in a suburb of the capital, Islamabad, for a court hearing in which the former military leader, Pervez Musharraf, faces charges in relation to Ms. Bhutto’s death in 2007.

The police said that gunmen traveling by motorbike and in a taxi sprayed Mr. Ali’s car with bullets, lightly wounding his bodyguard and killing a woman who was passing by when his car veered out of control. Television footage from the scene showed a bullet-riddled vehicle crashed by the roadside.

Mr. Ali died before he reached a hospital in Islamabad, where a doctor said he had been shot 13 times. The police said that Mr. Ali’s bodyguard returned fire and managed to wound one of the attackers. The police are searching for the attackers, all of whom escaped.