Under the massive trauma, Ali lost control of his car and hit a woman passing by and killed her, said another police officer, Mohammed Rafiq. His bodyguard returned fire and is believed to have wounded at least one of the attackers, Rafiq added.
Though Pakistan has experienced rampant violence in recent years, it's rare for such an attack to happen in the capital.
Hasan-Askari Rizvi, an independent political analyst, said it was difficult to say who might have been responsible for the attack because Ali was involved in a number of dangerous prosecutions.
But he said the fact that someone was able to kill such a prominent government official and then escape in what is supposed to be the most protected city in the country and highlights the inability of the state to protect its citizens against militancy.
"The Pakistani state is helpless," he said. "These groups have the initiative with them and the state simply reacts to that."
Members of the legal community have been especially vulnerable in Pakistan's ongoing war with militants. As there are no witness protection programs, people are often reluctant to testify in cases. Judges and lawyers have been threatened and attacked. As a result, the country has an abysmally low conviction rate for terrorism related cases.
Bhutto's husband, President Asif Ali Zardari, strongly condemned the prosecutor's slaying and called for a thorough investigation.
A motive for the killing was unclear, but Ali's involvement in the two particularly high-profile cases will likely be scrutinised closely.
Government prosecutors have accused Musharraf of being involved in the Bhutto assassination and not providing enough security to Pakistan's first female prime minister. Musharraf, who was in power when Bhutto was killed, has denied the allegations. At the time of the attack, he blamed the assassination on the Pakistani Taliban.
The Bhutto case has lingered for years in the Pakistani court system. A number of alleged assailants are on trial but no one has been convicted. The case burst into the headlines when Musharraf returned in March after four years in exile.
The prosecutor told reporters that he had received death threats recently in connection with the case but did not say from whom.
Ali's colleagues described him as a highly competent prosecutor.
"He had a vast experience of handling complicated and high-profile cases and because of his competence he was assigned the Benazir Bhutto case and some other cases," said Ashraf Gujar.
Ali was also the government's lead prosecutor in a case related to the 2008 terrorist attack on the Indian city of Mumbai that killed 166 people. The attack was blamed on the Pakistan-based militant group Lashkar-e-Taiba.
Pakistan has put seven men on trial on charges they assisted in the Mumbai siege, but the trial has made little progress. India has criticised Pakistan for not doing more to crack down on the militants blamed for the attack. Hafiz Saeed, the head of a group believed to be a front for Lashkar-e-Taiba, remains free, and many believe he enjoys the protection of the government. Lashkar-e-Taiba was founded years ago with the help of Pakistani intelligence to put pressure on India over the disputed territory of Kashmir.
Musharraf returned to Pakistan to make a political comeback despite Taliban death threats and a raft of legal cases against him. But his fortunes have gone from bad to worse since he arrived.
Judges barred him from running in the election, and a court this week banned Musharraf from running for public office for the rest of his life.
Musharraf is currently under house arrest on the outskirts of Islamabad in connection with several cases against him, including the Bhutto case. He also faces allegations of treason before the Supreme Court.
Ali was headed to a hearing related to Musharraf and the Bhutto case when he was killed.
Musharraf seized power in a military coup in 1999 when he was serving as army chief and ruled for nearly a decade until he was forced to step down in 2008 because of growing discontent with his rule.
Pakistan has experienced three coups, including the one led by Musharraf in 1999 that have helped stall the democratic process.
The May 11 election will mark the first time in Pakistan that a civilian government has finished its term and handed over power in democratic elections.
But the run-up to the election has proved especially treacherous with militants killing candidates and their supporters.
In Karachi on Friday, gunmen riding a motorcycle shot to death Sadiq Zaman Khattak, who was running for parliament from the Awami National Party, and his 6-year-old son, said police officer Mohammad Ali.
The Awami National Party has been repeatedly targeted by the Taliban because of its opposition to the militants. The Taliban have threatened two other secular parties as well, including the Muttahida Qaumi Movement, which controls Karachi.
In the second Karachi attack, gunmen riding on a motorcycle killed a prominent activist from the Muttahida Qaumi Movement, Mohammad Adil, said police officer Mohsin Khan.
No one has claimed responsibility for the attacks.
- AP