Two members of a banned leftist group who were holding a prosecutor hostage inside a courthouse were killed by police.
The prosecutor was seriously wounded and taken to hospital, said Selami Altunok, Istanbul's police chief. The lawyer was shot three times in the head and also in the body, according to a BBC report.
Police were in negotiation talks with the gunmen for around six hours before the siege ended, said Altunok in an AP report.
Special forces entered the building earlier on Tuesday, according to news agency Dogan, and evacuated the building.
Dramatic images were seen on social media of a gun being held to the head of Mehmet Selim Kiraz at a court house in Istanbul.
The Turkish government banned live TV coverage of the incident, citing security concerns.
It's not yet known how the intruders managed to smuggle arms into the legal building.
The prosecutor was identified as Mehmet Selim Kiraz, according to state-run Anadolu Agency and TRT, state television. He is the lawyer investigating the death of Berkin Elvan, a teenager hit by a police gas canister during anti-government protests in 2013.
The militants from the banned leftist organisation took the lawyer hostage at midday on Tuesday. They gave authorities three hours to meet their demands including asking the police to take responsibility for the teenager's death, according to a website close to the Revolutionary People's Liberation Party-Front (DHKP-C).
The DHKP-C is considered a terrorist organisation by Turkey, the U.S. and the European Union.
The group has carried out several attacks, including a suicide bombing on the US Embassy in 2013 that killed a security guard.