A Turkish prosecutor and two gunmen who took him hostage have been killed after a shootout at a courthouse in Istanbul.
Gunshots were heard and smoke was seen rising from the scene after special forces stormed the building.
Mehmet Selim Kiraz was apparently taken hostage because he had headed an inquiry into the death of a boy during anti-government protests in 2013.
A banned Marxist revolutionary group is said to be behind the hostage taking incident.
A statement posted online had said the prosecutor would be killed if the group’s demands were not met.
Istanbul’s police chief Selami Altunok said that police had negotiated with the gunmen for six hours, but eventually stormed the courthouse “because of gunshots heard from inside the prosecutor’s office”.
The two gunmen died during the operation, while Mr Kiraz was badly wounded and later died of his injuries, officials said.
Turkish Prime Minister Ahmet Davutoglu said the attackers had posed as lawyers to enter the courthouse.
The gunmen had released dramatic images of a gun being held to the head of Mehmet Selim Kiraz as the hostage crisis unfolded.
The Turkish government banned live TV coverage of the incident, citing security concerns.
Sukriye Erden, a lawyer negotiating with the hostage takers, told the BBC that they had demanded that the police announce the names of four members of the security services who they said were connected to the death of the boy, Berkin Elvan.
Elvan, who was then 14, was struck in the head by a police tear gas canister in June 2013 as he went to buy bread during mass demonstrations that began in Istanbul and spread across Turkey.
He died in an Istanbul hospital last year, after spending nine months in a coma.
Recep Tayyip Erdogan, now Turkey’s president, inflamed passions shortly after the teenager’s death when he said the boy had been carrying a slingshot and had been “taken up into terrorist organisations”.
Suspected members of the Revolutionary People’s Liberation Party-Front (DHKP-C) took the prosecutor hostage on the sixth floor of the Caglayan court house.
The DHKP-C is considered a terrorist group by Turkey, the European Union and US. It said it carried out a suicide bombing in February 2013 at the US embassy in Ankara, where a security guard was killed.
In January, a man linked to the banned Marxist group was arrested near the prime minister’s offices in Istanbul, reportedly after throwing two grenades that failed to explode.
There will be questions over how two of the group’s members managed to breach security at Istanbul’s main courthouse, with such tragic consequences, the BBC’s Mark Lowen reports from Istanbul.