Medan (Indonesia) (AFP) - An Indonesian teenager who stabbed a priest in a church and tried to set off a homemade bomb was obsessed with the Islamic State (IS) group leader, a minister said Monday.

The 17-year-old attempted Sunday to set off the crude, low-grade explosive as the Catholic priest held mass in the packed church in Medan on Sumatra island, and then stabbed him with a knife.

The explosive, which authorities compared to a firecracker, did not detonate properly and only gave off smoke while the priest sustained minor injuries to his arm.

The congregation tackled the attacker after he ran at Father Albert Pandiangan and knifed him, stopping the teenager before he could do more harm.

Security Minister Wiranto said that the attacker was fixated on the leader of IS. The group's influence has been blamed for a string of recent attacks and attempted attacks in Muslim-majority Indonesia.

"From the mobile phone confiscated by authorities, this kid is obsessed with Abu Bakr al-Baghdadi from ISIS," the minister told reporters, referring to the jihadist group by a different name.

Wiranto, who like many Indonesians goes by one name, said the words "I love al-Baghdadi" were found written on the attacker's backpack, although officials did not believe he had joined any terror network.

A search of his rented room turned up copper cables, gunpowder and light bulbs, materials that could be used to assemble simple bombs, said Wiranto.

The backpack he carried during the attack contained cut up sections of a pipe, packed with gunpowder. The devices were not capable of producing a serious explosion, said Wiranto.

An eyewitness said the assailant was seen fiddling in his bag, which produced a small explosion, before he ran towards the priest.

It was the latest attack that was either linked to or thought to be inspired by IS in Indonesia.

A suicide bombing and gun attack in the Indonesian capital in January claimed by IS killed four attackers and four civilians. In July an IS-linked suicide bomber attacked a police station on Java island, causing minor injuries to one officer.

Sunday's incident was also the latest assault on a religious minority in Indonesia, which is home to substantial numbers of Christians, Hindus and Buddhists.