The suspect was reportedly being taken to his cell when he stabbed his victim to death.
Turkish media say a policeman has been stabbed to death in Istanbul by a suspected Islamist militant who was in custody.
The state news agency Anadolu said the aggressor had been driven to police headquarters and was being taken to his cell when he struck.
He was immediately shot dead by the security forces.
The man suspected of links to the so-called Islamic State had been detained because he was suspected of preparing an attack.
The officer, named as Sinan Acar, was taken away by ambulance but died in hospital. Despite a temporary media blackout over the attack a crowd gathered outside.
There are questions over why apparently his attacker had not been handcuffed.
Turkey has been struck by several fatal attacks attributed to ISIL, the last one being at New Year.
Suspects are regularly arrested; on Saturday four were detained west of Istanbul.
State media said they were on a mission to plan an attack.