A Turkish police officer was stabbed to death in Istanbul late Sunday by a suspected Islamic State terrorist, state media reported.

The knife-wielding attacker reportedly had been arrested on suspicion he was preparing to carry out a suicide attack, and was in custody en route to the police station when the stabbing unfolded. The suspect reportedly was shot and killed after the stabbing.

The officer died in an ambulance on the way to the hospital and the attacker was shot dead immediately after the attack. It is not yet known how the suspect was able to keep a knife hidden following his arrest.

BATTLE TO FREE RAQQA PUTS COALITION UP AGAINST BOOBY-TRAPS, CAR BOMBS AND MINES

Turkey, which has taken in a large number of refugees fleeing the protracted conflicts in neighboring Syria and Iraq, has been the site of several ISIS-inspired attacks in recent years.

The latest killing came just days after an alleged ISIS plot involving a drone attack on Turkey's Incirlik air base -- which is used by the U.S. Air Force -- was foiled.

‘SOPHISTICATED’ ISIS PLOT TO BOMB AIRLINER RAISES SERIOUS QUESTIONS

Renad Bakiev, a Russian national who previously traveled to Syria to join ISIS, was detained in the southern city of Adana for planning the drone attack, police said Thursday.

The Associated Press contributed to this report.