Indonesian police have foiled plans for a Christmas suicide bombing after killing three suspected militants Wednesday and discovering a cache of bombs.

A firefight erupted at a house in South Tangerang 25 kilometres (15 miles) outside the capital Jakarta, with police saying the alleged militants had opened fire at officers, news agency AFP reported.

"We asked the three men to surrender but they fought, with one of them throwing a bomb (at officers). Thankfully the bomb didn't explode and we took firm action against them," said national police spokesman Rikwanto, who goes by one name.

He said the group had planned to stab a police officer at a police station and wait for crowds to gather before launching a suicide bomb attack around the Christmas holidays.

The plot was disclosed by a member of the group who was arrested earlier on Wednesday and tipped off police about the three militants and their whereabouts, police said.

The raid came less than two weeks after police arrested four militants including a female suicide bomber in Bekasi, east of Jakarta. They were plotting to bomb one of the guard posts at the presidential palace.

The men in South Tangerang have links to the Bekasi group, Rikwanto said. Some are members of a local radical outfit which has pledged allegiance to the Daish group.

Police said investigations are continuing into the larger network and its agenda.

Indonesia suffered a string of deadly homegrown attacks during the 2000s -- including the 2002 Bali bombings which killed over 200 people.

A sustained crackdown has weakened many of the most dangerous extremist networks but there have been fears of a resurgence in militancy.

Police believe hundreds of Indonesians have travelled to Syria to fight with militant groups including Daish.