The killing took place in daylight on a Tehran street.
Judiciary spokesman Jamal Karimi Rad said Massoud Moghadas was shot dead in his car after leaving his central Tehran office on Tuesday.
“We do not know anything about the identity of the assassin,” he added.
Witnesses quoted by local media said he was shot by at least one person on a motorbike.
Tehran police chief Morteza Talaei said the assailant escaped, a motive for the killing was unclear, and police would look at Moghadas’ past cases for clues.
Police blocked the street and cordoned off the shooting scene, Ahmad Qasir Street, also known by its previous name, Bucharest Street.
No one has claimed responsibility for the killing.
Moghadas sentenced Ganji, the country’s highest profile political prisoner who is currently on hunger strike, to six years in prison in 2001 for implicating government officials in the murders of opposition figures.
Moghadas headed the Tehran judiciary complex and specialised in cases of social vice, Karimi Rad said.