Speaking at a press conference, National Police spokesman Dedi Prasetyo said the arrests took place over the weekend in Bekasi city, near Jakarta, and in Bitung city in the northern province of Sulawesi.
Five militants were nabbed in Bekasi, while another was shot dead there as he was about to explode a bomb, he said, adding that two others were arrested in Bitung as they were on the way to hook up with other militants elsewhere on Sulawesi island.
All the eight are believed to be members of Jamaah Ansharut Daulah, or JAD, a militant network linked to Islamic State.
Dedi said the militants intended to target mass gatherings, especially the protest rallies that have been taking place almost daily in Jakarta relating to the presidential and legislative elections that took place on April 17.