A chief prosecutor and two militant members of a banned communist group, who held him hostage inside a courthouse in Istanbul, have died according to police.

The men believed to be members of the banned Revolutionary People’s Liberation Party-Front (DHKP-C) took Mehmet Selim Kiraz hostage in the capital on Tuesday, in an act of revenge over the death of a teenager during anti-government protests in 2013 - which he was investigating.

After six hours of police negotiations, security forces entered the building when gunshots were heard from inside the prosecutor's office, said Istanbul's police chief Selami Altinok.

The attackers were shot dead by police and Mr Kiraz was severely wounded after being shot in the head during the rescue operation. He later died in hospital after undergoing surgery, the government and hospital officials announced.

Turkish special forces in front of the courthouse where a Turkish was taken hostage (AFP/Getty Images)

The militants earlier posted pictures on social media of a gun being held to Mehmet Selim Kiraz’s head.

They threatened to shoot him unless authorities met their five demands, including forcing policemen believed to have killed the teenager to confess to the death, the Associated Press reported.

The group’s flag could be seen in the background as Mr Kiraz was held gagged and with his hands tied in front of him.

Speaking in Ankara, Turkish Prime Minister Ahmet Davutoglu revealed that the hostage takers have been identified, and said that they had dressed up as lawyers in order to sneak in arms inside the Çağlayan Justice Palace, thought to be the largest courthouse in Europe.

Deputy Chief Prosecutor Orhan Kapici confirmed that the incident was related to Kiraz's investigation into the boy's death.

According to a statement released on halkinsesi.tv, the militants gave authorities until 3.36 pm local time (1.36pm BST) to meet their demands - three hours after they stormed the court building.

But that deadline passed without a word from Turkish authorities about Mr Kiraz's wellbeing, until the latest statement by Altinok.

As evening fell, gunshots and explosions were heard as smoke rose from the building, a witness told Reuters.

Security forces were seen outside and an ambulance raced to a rear door, sirens blaring, the witness added.

Deputy Chief Prosecutor Vedat Yiğit earlier told the Hürriyet Daily News that negotiations between militants and police were conducted via a mediator, and that police were attempting to resolve the issue "without anyone being hurt."

"Our negotiators and Umit Kocasakal, the head of the Istanbul Bar Association, are talking to the militants," Istanbul Police Chief Selami Altunok said before the hostage situation ended.

Turkish police stand guard as courthouse employees leave the Justice Palace in Istanbul (Reuters)

Witnesses said shots were heard at the court house when Mr Kiraz was seized and special forces have since entered the building, which was evacuated and cordoned off.

“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, adding that the attackers also claimed to have explosives.

Live coverage of the hostage crisis stopped on Turkish television on Tuesday afternoon when a ban was imposed by the government. It was reportedly one of more than 150 such gagging orders issued in the last four years.

In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Show all 20 1 /20 In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey Riot policemen shield themselves as fireworks thrown by protesters explode next to the statue of a bull, during an anti-government protest in the Kadikoy district of Istanbul Reuters/Stringer In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey Fireworks thrown by protesters against Turkish riot police explodes and illuminates the scene during a demonstration in Istanbul In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey People protect themselves behind a trash can as anti-riot olice fires water cannon to disperse thousands of people demonstrating following the death of Berkin Elvan In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey Turkish riot police use tear gas to disperse protesters during an anti government demonstration in Istanbul In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey Middle East Technical University (ODTU) students march along a main highway to protest the death of Berkin Elvan in Ankara. Police and protesters clashed in Turkey's two biggest cities following the death of the 15-year-old boy who suffered a head injury during anti-government demonstrations in 2013 In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey A Turkish protester stands in front of a riot police's water cannon vehicle during a demonstration in Istanbul In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey Turkish riot police fires tear gas to disperse protesters during a demonstration in Istanbul In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey A demonstrator opens his umbrella as police uses a water cannon during clashes between protesters and riot police at Istiklal avenue in Istanbul In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey Protesters are hit by water cannon during clashes with riot police in Kadikoy, on the Anatolian side of Istanbul In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey A riot police stands near a burning barricade during clashes with riot police in Kadikoy, on the Anatolian side of Istanbul In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey A protester wearing a gas mask stands in front of an empty bus during clashes with riot police in Istanbul In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey A protester throws gas canister back to policemen during clashes with riot police in Istanbul In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey A protester holds a picture of Berkin Elvan during clashes with riot police in Istanbul In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey A protestor throws a stone at riot police lined up to hide behind shields during clashes with police in Istanbul In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey A protester wearing a gas mask stands during clashes with police in Istanbul In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey Anti-government protesters run as riot police fires a water cannon in Ankara during a demonstration following the death of a teenage boy wounded in mass anti-government demonstrations last year. About 1,000 people also staged a rally outside an Istanbul hospital in solidarity with 15-year-old Berkin Elvan, who was walking to buy bread when he was struck in the head by a tear gas canister during the unrest in the city in June 2013 In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey The young teenager was the eighth person to be killed in the Gezi Park protests In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey The coffin of Berkin Elvan is carried in Istanbul In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey The sister of Berkin Elvan (C) cries as his coffin of is carried in Istanbul. Berkin Elvan, who has been in a coma since June 2013 after being struck in the head by a gas canister during a police crackdown on protesters, died on 11 March, his family announced via Twitter In pictures: Protests spread in Turkey after family confirms the death of teenager Berkin Elvan Turkey The mother of Berkin Elvan (C) cries as his coffin of is carried in Istanbul

Mr Kiraz is investigating the death of 15-year-old Berkin Elvan, who was hit by a police gas canister fired during nationwide anti-government protests in 2013.

Tens of thousands of people took to the streets following his injury and subsequent death after 269 days in a coma.

Berkin's death – the eighth related to protests in Gezi Park - re-ignited anger at the government, becoming a further symbol of police and government impunity.

Militants' conditions for the prosecutor's release include a television confession by the police officers suspected of killing Elvan, the prosecution of the officers responsible in a “people’s court” and the acquittal of all people being tried for participation in solidarity rallies after his death, the Hurriyet Daily News reported.

Anti-government protesters mourn the death of Berkin Elvan, which the prosecutor was investigating (ADEM ALTAN/AFP/Getty Images)

Hüseyin Aygün, a Turkish lawyer and member of parliament with the Republican People's Party, wrote on Twitter that people want “justice, not revenge” for Berkin’s death.

He spoke to the boy’s father, Sami, after the crisis broke out and quoted him as saying: "My son is dead, but someone else should not die. The prosecutor must be released. Blood cannot be washed with blood."

“I don't want anyone to even get a nosebleed. Until today, I've only demanded justice, and I only want a fair trial,” Mr Elvan wrote later on Twitter.

The DHKP-C has been listed as a terrorist organisation by Turkey, the European Union and US after a string of assassinations and suicide bombings since its foundation in the 1970s.

Today, Istanbul was one of dozens of Turkish cities and provinces hit by a massive power cut today believed to be the country’s worst blackout in years. Shop workers sit in candle light at their shop after a major power cut in Istanbul, Turkey 31 March 2015.

In January, the DHKP-C claimed responsibility for a suicide bombing at a police station in Istanbul’s historic Sultanahmet district that killed one officer and wounded another, claiming it was to “settle scores” over Berkin's death.

Marxist-Leninist militants said on their website the ruling AK Party was responsible for the explosion and a grenade attack they launched on police at a historic palace near the Prime Minister’s office in Istanbul the week before.

The DHKP-C was also behind the bombing of the US embassy in Ankara in 2013.