A suspected militant who attacked police on the outskirts of Jakarta with a machete and pipe bombs has died from gunshot wounds.
Three officers including a local police chief were injured and the attacker, who was shot several times, died on the way to hospital due to blood loss from wounds to his legs and stomach, Jakarta police spokesman Awi Setiyono said on Thursday.
Local television footage showed the man limping around a busy city road carrying weapons including what appeared to be a pipe bomb.
Police said the injured officers had stab wounds and had been hospitalised but the attacker also threw at least one explosive.
The officers were monitoring a protest when the incident occurred on Thursday morning in the satellite city of Tangerang.
"This sudden and brutal attack was committed by a man using a sharp weapon. One officer got hurt, another, the head of the patrol unit, tried to help him but he was also attacked and the chief of the precinct was also stabbed," national police spokesman Inspector General Boy Rafli Amar told Australian Associated Press.
"Our officers at that time were managing the traffic in the morning when people going to office, to school. So, the place was crowded."
The attacker, Sultan Azianzah, 21, was unemployed and a member of Daulah Islam, a hardline group in Ciamis in West Java province, Setiyono said.
Radical Islamic groups in Indonesia, the world's most populous Muslim nation, have been weakened by a sustained security crackdown since the 2002 bombings on the tourist island of Bali.
But IS's high profile attacks in the Middle East and Europe and the group's online propaganda have helped to recruit a tiny minority of Indonesians to their cause, mostly teenagers and young adults.
Police seized sharp weapons, pipe bombs and an IS sticker as evidence in the Tangerang attack.
Amar said Azianzah appeared to have thrown one pipe bomb which hadn't exploded and he was carrying a second explosive when arrested.
The attack unfolded after officers intervened when he tried to put an IS symbol on a police post.
It's believed Azianzah travelled to greater Jakarta with the intention of attacking police.