An Istanbul prosecutor died from his wounds after security forces stormed the office where members of a far-left Turkish group took him hostage on Tuesday, killing his two captors.
The Revolutionary People's Liberation Party-Front (DHKP-C) had published a picture of the prosecutor with a gun to his head and said it would kill him unless its demands were met.
Turkish President Tayyip Erdogan said Mehmet Selim Kiraz had been shot three times in the head and twice in the body. He died despite being rushed to hospital for emergency surgery.
Six hours after the standoff in a courthouse in central Istanbul began, explosions and gunfire could be heard coming from the building and smoke billowed from a window, a Reuters witness said.
A few minutes later, two ambulances, sirens wailing, raced away from the scene.
Police chief Selami Altinok said authorities had established lines of communications with the hostage-takers, but had been forced to act when shots were heard from inside the room where Kiraz was being held.
Kiraz 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 in anti-government protests.
The DHKP-C said on its website it wanted the police officer it blames for Elvan's death to confess on television, the officers involved to be tried in "people's courts", and charges against those who attended protests for Elvan to be dropped.
During the firefight, both captors were killed, Altinok said at a media conference shortly after the operation had finished.
"Our forces have worked with patience and endurance for six hours and took all necessary security measures," he said.
Speaking at the scene, Erdogan praised the police and said the siege had begun when two gunmen, disguised as lawyers, had entered the courthouse.
"We cannot underestimate the seriousness of this incident," he said, noting that security at courthouses would be reviewed.
Witnesses said they heard gunshots as the hostage-takers entered the building.
"We were on the sixth floor. A black-haired man wearing a suit entered the prosecutor’s room and fired a gun three times," Mehmet Hasan Kaplan, who works in the building, told Reuters. The attackers also claimed to have explosives, he said.
In a brief video message on a widely followed Twitter account describing itself as that of Elvan's family, the boy's father had seemed to call on the group not to harm Kiraz.
"We want justice. We don't want anyone to shed even a drop of blood. We don't want other mothers to cry," Sami Elvan said.
Television footage earlier in the day had shown special forces officers entering the courthouse and officials being escorted out.
The United States, European Union and Turkey list the DHKP-C as a terrorist organization. It was behind a suicide bombing at the U.S. Embassy in 2013. In 2001, two policemen and an Australian tourist died in a DHKP-C attack in central Istanbul.