A senior Turkish prosecutor and his two hostage-takers were killed when security forces launched an operation to free the official in a bloody end to a six-hour standoff in Istanbul.
Two radical leftist militants had earlier, on Tuesday, taken the Istanbul prosecutor Mehmet Selim Kiraz hostage in his office, putting a gun to his head and threatening to kill him if their demands were not met.
Their demands related to the investigation Kiraz was leading into the killing of teenager Berkin Elvan, who died in March last year after spending 269 days in a coma from injuries inflicted by police in anti-government protests in the summer of 2013.
The authorities initially tried negotiating with the captors on a hugely tense day in Turkey's largest city which also suffered a major power cut.
But they decided to launch an operation to free the prosecutor when gunfire was heard in their mobile phone communications with the captors, Istanbul police chief Selami Altinok told reporters outside the courthouse.
Altinok said the two "terrorists" had been killed. Kiraz was taken to hospital but rapidly succumbed to his wounds, doctors said in a statement on television.
"When he arrived he had gunshot wounds both to his head and his chest. His breathing and heart had stopped," the statement said.
President Recep Tayyip Erdogan, arriving on a visit to Romania, said the attackers had entered the courthouse disguised in legal robes.
He said Kiraz had suffered three gunshots to the head and two to his body, without elaborating further.
'Attack on Turkish democracy'
Prime Minister Ahmet Davutoglu said: "as a nation we see this attack not only an attack against our prosecutor Mehmet Selim Kiraz, but also an attack against the Turkish judiciary, Turkish democracy and all the citizens in Turkey."
He told reporters in Ankara that despite the bloodshed, the police operation has "largely achieved its goal."
The hostage-taking was claimed by the radical Marxist Revolutionary People's Liberation Party-Front (DHKP-C), which has been behind a string of attacks over the last years.
The group earlier published pictures showing one of the militants - his face concealed by a scarf with the group's red and yellow insignia - holding a gun to Kiraz's head.
Davutoglu said the attackers had both been identified and were in their 20s.
The group had given an afternoon deadline for the prosecutor to identify the police officers who they say were behind the killing of Elvan and force them to make a "live confession" or he would be shot.
The Turkish television watchdog ordered a media blackout on reporting of the standoff, forcing Turkish television channels to cut the live transmissions of the incident.
'Blood can't be washed away'
Elvan succumbed to injuries sustained when he was hit by a tear gas canister fired by police in mass protests in the early summer of 2013 against the government of Erdogan, who was then premier.
He was aged 15 at the time of his death, which was followed by mass nationwide protests that were also put down by the police.
Elvan has since become an icon for the Turkish far-left and his supporters accuse the authorities of covering up the circumstances of his death.
Despite the investigation, no police officer has been brought to trial over the case, to the fury of Elvan's supporters.
In a phone call with opposition lawmaker Huseyin Aygun, Elvan's father Sami pleaded there be no more bloodshed, the Hurriyet newspaper reported.
He said: "My son died but I don't want any other person to die. The prosecutor must be released. Blood cannot be washed away with blood."
The DHKP-C is considered a terrorist group by Turkey, the European Union and the United States.
It claimed a January 1 attempted grenade attack on police guarding the Dolmabahce palace in Istanbul, where the prime minister has his office in the city, saying it was revenge for Elvan's killing.
It also claimed a suicide attack in Istanbul later that month, but in a bizarre sequence of events then withdrew the claim, saying it had made a mistake.
The hostage-taking coincided Tuesday with the worst power cut Turkey has seen for 15 years, which has caused chaos in Istanbul.
There was no indication of a link between the two events although some reports said the armed radicals had been able to enter the courthouse as the metal detectors were not working due to the electricity stoppage.
Erdogan had sparked an outcry after he called Elvan a thug with links to a "terrorist organisation" and encouraged his supporters at a rally to boo the teenager's mother.
Track Latest News Live on NDTV.com and get news updates from India and around the world