An Indonesian Islamic militant was jailed for seven years on Monday after he built bombs at his house and plotted to attack police stations.

Muhammad Toriq was arrested in September after police discovered detonators, boxes of nails and explosive materials at his home in a suburb of the capital Jakarta.

Neighbours alerted authorities after seeing smoke rising from Toriq's house. He initially fled but later turned himself in and was charged with plotting to bomb two police stations in Jakarta in September.

"After learning how to build bombs, the defendant made them at home," said Judge Yuferry F. Rangka as he handed down the sentence at a Jakarta court.

"His actions have caused anxiety in the community."

Police said previously that Toriq had links to an outlawed radical group called the Islamic State of Indonesia.

A calm-looking Toriq told reporters after the trial that he accepted the verdict: "I accept the decision. It's God's will."

Indonesia, the country with the world's biggest Muslim population, has waged a crackdown on militant groups over the past decade since a string of attacks on Western targets, including the 2002 Bali bombings.

The clampdown has weakened key militant groups, and recent attacks have been low-impact and have targeted Indonesian security forces.