Two members of a banned leftist group and a prosecutor they held hostage inside a courthouse in Istanbul have died after a shootout between the hostage takers and Turkish police.
Police had negotiated with the gunmen for six hours before the violent end to the hostage situation, said Istanbul police chief Selami Altinok.
The prosecutor, identified by the state-run Anadolu Agency and state television TRT as Mehmet Selim Kiraz, was shot in the head during the standoff and rushed to hospital where doctors tried to save his life, Turkish president Recep Tayyip Erdogan said earlier.
Turkish prime minister Ahmet Davutoglu and hospital officials later announced he had died.
Private news agency Dogan reported police special forces had entered the building, which was evacuated. It was not clear how the assailants sneaked the arms into the courthouse.
Mr Kiraz was the prosecutor investigating the death of a teenager who was hit by a police gas canister fired during nationwide anti-government protests in 2013.
A website close to the left-wing DHKP-C group said that militants from the banned organisation had taken the prosecutor hostage at midday and had given authorities three hours to meet five demands, including forcing policemen held responsible for the teenager's killing to confess to the death.
The group also demanded that the policemen be tried by "people's courts" and for court officials to drop prosecutions or investigations against people who took part in protests denouncing the boy's death. The website showed a picture of someone holding a gun to a man's head with posters from the group in the background.
Deputy chief prosecutor Orhan Kapici confirmed that the incident was related to Mr Kiraz's investigation into the boy's death.
The DHKP-C, which seeks a socialist state, is considered a terrorist organisation by Turkey, the US and the European Union.
The group has carried out sporadic attacks, including a suicide bombing at the US embassy in 2013 which killed a security guard. The group was more active in the 1970s.
Speaking in Ankara, Mr Davutoglu said the hostage takers have been identified and had dressed up as lawyers in order to sneak arms inside the courthouse.