Turkish security forces have carried out an operation to rescue a prosecutor held captive at an Istanbul courthouse, killing the two hostage-takers.

Selami Altiok, the city's police chief, said in a news conference on Tuesday that the attackers had been shot dead and that prosecutor Mehmet Selim Kiraz was critically wounded during the operation. Kiraz later died at the hospital.

Mehmet Selim Kiraz was investigating the killing of Berkin Elvan, who died in March last year after spending 269 days in a coma due to injuries inflicted by police in the mass protests of early summer 2013.

The hostage-takers, who belonged to the Revolutionary People's Liberation Party-Front (DHKP/C), an outlawed leftist group, had announced a list of demands for the release of the prosecutor, saying that the officer who shot Elvan must appear on TV and confess his guilt.

Altiok said that police had been in communication with the armed men for six hours prior to the operation.

"After gunshots were heard from the room, security forces carried out the operation," Altiok added.

Gunshots and blasts were heard outside the courthouse during the operation, according to witnesses.

Turkish media earlier had showed photos of an armed man holding a gun to the prosecutor's head while his hands were tied.

Al Jazeera's Bernard Smith, reporting form outside the courthouse, said that investigators at the scene were focusing on how the guns used were brought into the well-protected building.

"Only lawyers are entitled to go into the courthouse without being searched," Smith said.

The hostage-takers threatened to kill Kiraz if the officer who shot Elvan was not arrested, setting a deadline of three hours for their demands to be met, according to a statement on the group's website.

List of demands

The hostage-takers had announced a list of demands for the release of the prosecutor, saying that the officer who shot Elvan must appear on TV and confess his guilt.

The police officer must also be tried in a people's court, not in the state courts, the list read.

Another demand was that the rights of those who attended rallies in solidarity with the Elvan family must be reinstated and that the prosecutions against them should be abolished. The group also demanded a safe exit of the armed men behind the hostage-taking.

Sami Elvan, Berkin's father, said on Twitter in a video statement that he did not want to see the prosecutor hurt.

The judicial process in the case of Berkin Elvan's death has been widely criticised in Turkey.

The Istanbul Police Department did not forward the identities of the policemen suspected of killing Elvan to the prosecutor's office until March, a year after the teenager's death.