Indonesian police say a sword-wielding man who attacked a church congregation and injured four people during Sunday Mass wanted to join the Islamic State group.

Monday's announcement came after some 100 people were attending the service at a Catholic church in Yogyakarta province on Java island when the 23-year-old suspect, identified as Suliyono, barged in wielding a one-meter sword.

He soon began attacking terror-stricken people, seemingly indiscriminately, witnesses and police said.

Four people, including 81-year-old German-born priest Edmund Prier who was standing at the altar of St Lidwina Church, were seriously injured, officials said.

The Indonesian attacker, who decapitated statues of Jesus Christ and the Virgin Mary during the incident, was later shot in the leg after ignoring a police warning shot.

Police said that after the detention of Suliyono it had emerged that he had made a passport application as he attempted to go to Syria, but the request failed. "He ended up launching the attack here,” explained national police chief Tito Karnavian.

He said police are still investigating whether Suliyono was a “lone wolf terrorist” or part of a group. Local police detective Fendi Timur said earlier that counterterrorism police would be involved in the investigation.

Sunday's bloodshed followed several attacks against churches by Islamic militants in Indonesia, the world's most populous Muslim nation.