The two members of the terrorist group Revolutionary People's Liberation Party-Front (DHKP/C) took prosecutor Mehmet Selim Kiraz hostage on Tuesday as an act of revenge over a teenager's death during anti-government protests in 2013.
Kiraz, who was also killed in the rescue attempt, was leading an investigation into the death last March of 15-year-old Berkin Elvan, who died after nine months in a coma from a head wound sustained from a police gas canister.
Police used tear gas to break up protests in Okmeydanı, Elvan's neighborhood in central İstanbul, the Radikal newspaper said on its website.
In the working-class İstanbul district of Gazi, scene of frequent clashes and where the group has sympathizers, police used tear gas and water cannon to stop protesters from marching on a police station, it said.
Elvan died during protests that began as an effort to save a park from development before swelling into the biggest anti-government movement in a generation. President Recep Tayyip ErdoÄŸan has described Elvan as a "terrorists' pawn."
The DHKP/C, designated by Turkey, the US and the European Union as a terrorist organization, is a Marxist group formed in the late 1970s that has been behind a series of assassinations and suicide bombings, including fatal attacks on the US Embassy. The Turkish police have been a frequent target too.
A website close to the group published a picture of the prosecutor with a gun to his head on Tuesday. Authorities tried to negotiate for Kiraz's release, but he was shot in the head and body and died of his wounds.