Plainclothes police detain a suspect after an attempted suicide bombing at St. Yoseph Catholic Church in Medan, Indonesia. (Dedi Sinuhaji/European Pressphoto Agency)

A man armed with a bomb and an ax intended to wreak havoc during a packed Sunday Mass celebration in Indonesia, but his bomb burst into flames rather than explode. Police told local media that the man was carrying items marked with an Islamic State insignia.

The attacker did manage to swing his ax at the church's 60-year-old priest, slightly injuring his hand. Congregants were able to subdue the attacker until police arrived.

Indonesia is home to more Muslims than any other country. Almost all of its roughly 250 million people are moderate Sunni Muslims, though there is a significant Christian minority. Compared with other large Muslim countries, militancy is relatively rare in Indonesia, though extremist groups have carried out minor attacks, including of churches. The biggest attack in the country occurred in 2002 when terrorists bombed nightclubs on the island of Bali, killing 202, including 88 Australians. Since then, the government has sustained a massive crackdown on militant cells.

But the incident at the church in Medan, Indonesia's third-largest city, marks the second Islamic State-inspired attack in the country this year. The Islamic State, also known as ISIS, has called on supporters worldwide to carry out attacks at home, rather than join the militant group in Syria, Iraq and Libya, where it holds territory. On Jan. 14, four men attacked the business district of Indonesia's capital, Jakarta, with guns and explosives, killing four. The Islamic State asserted responsibility.

Security officials say that about 500 Indonesians have traveled to Syria and Iraq to join the Islamic State, according to Reuters. One in five of them is thought to have returned home.

Responding to growing anxiety that the militant group could gain a foothold in Indonesia, as it appears to have in Bangladesh, for instance, the government recently tightened anti-terrorism laws that were passed after the Bali bombings.

The police in Medan are investigating the church attack suspect's connections to other known Islamic State operatives. A police spokesman told the Associated Press that the 18-year-old suspect said he had not been working alone, but provided no details.

A witness quoted in the Jakarta Post made the attacker sound like a relative novice. "He was fidgety the whole time," said the churchgoer, identified only as Vero. "He also could not follow our ritual."

As the sermon began, Vero said, the man took cables out of his backpack and connected them to something she suspected was the detonator. He only managed to injure himself, as the bomb more or less burst into flames. The crowd rushed out, panicked, but alive.

Read More:

Southeast Asia could be a haven for displaced Islamic State fighters

High-profile Guantánamo prisoner makes his first appearance before a review board

With bombings, Thai militants appear to be sending a message to the junta