The men were arrested late on Wednesday in the country's second-largest city, Surabaya, with bomb-making material, guns and a suicide-bomb vest, police spokesman Boy Rafli Amar said.
"Their plan was to attack using a bomb during the holy month of Ramadan," Amar told reporters, adding that their target was the police.
"They had prepared a suicide bomb."
Ramadan began this week.
Authorities are on high alert after a militant attack in the heart of the capital, Jakarta, in January in which eight people, including the four attackers, were killed.
Islamic State claimed responsibility, marking the first time known supporters of the group, which is based in the Middle East, had carried out an attack in Southeast Asia.
Amar said the suspects arrested on Wednesday were believed to have been guided by Islamic State teachings and that officials were investigating where they got their weapons.
Related news:
> Philippine island rebels free 10 Indonesian hostages
> Activists raise concern over Indonesian anti-terror law
> Indonesia to set up "crisis center" after Philippine kidnappings - minister