An Istanbul prosecutor and two hostage-takers are dead after a courthouse siege in central Istanbul ended in a bloody shootout with security forces.

The Revolutionary People's Liberation Party-Front (DHKP-C) had published a picture of prosecutor Mehmet Selim Kiraz with a gun to his head and said it would kill him unless its demands were met.

Turkish president Tayyip Erdogan said Mr Kiraz had been shot three times in the head and twice in the body. He died despite being rushed to hospital for emergency surgery.

His two captors also died as security forces stormed the building, six hours after the standoff began.

Explosions and gunfire could be heard coming from the building and smoke billowed from a window as the attack unfolded. A few minutes later, two ambulances, sirens wailing, raced away from the scene.

Police chief Selami Altinok said authorities had been talking to the hostage-takers, but had been forced to act when shots were heard from inside the room where Mr Kiraz was being held.

Both captors were killed during the firefight, Mr 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, Mr 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, said.

The attackers also claimed to have explosives, he said.

'Blood cannot be washed away with blood'

Mr 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.

Elvan died after sustaining major injuries from police during the deadly riots at Istanbul's Taksim Square and Gezi Park in June 2013.

A brutal police crackdown on May 31, 2013 against a peaceful sit-in to prevent 600 trees from being cut down in a redevelopment scheme for Gezi Park sparked June's nationwide protests against the prime minister.

Elvan was the sixth person to die in violence during the nationwide protests and his death reignited anti-government demonstrations across Turkey as thousands clashed with police.

The teenager has since become an icon for the Turkish far left and his supporters accuse the authorities of covering up the circumstances and perpetrators of his death.

Despite the investigation, no police officer has been brought to trial over his death, to the fury of Elvan's supporters.

In a phone call with opposition MP Huseyin Aygun, the dead teenager's father Sami urged against bloodshed, the Hurriyet newspaper reported on its website.

"My son died but I don't want any other person to die. The prosecutor must be released. Blood cannot be washed away with blood," Mr Elvan said.

The US, European Union and Turkey list the DHKP-C as a terrorist organisation.

It was behind a suicide bombing at the US Embassy in 2013.

In 2001, two policemen and an Australian tourist died in a DHKP-C attack in central Istanbul.

The Turkish prosecutor was probing the death of teenager Berkin Elvan, who died after being injured by police in anti-government protests. ( Reuters: Osman Orsal )

AFP/Reuters