Islamic State has claimed responsibility for an attack on a Shia Muslim mosque in Bangladesh on Thursday, in which a cleric was killed and three other people were wounded.

In the second attack on the country’s tiny Shia community in a month, witnesses said three young men stormed into the mosque in the north-western Bogra district and shot at worshippers indiscriminately during prayers.

“The attackers entered the mosque and opened fire on the devotees after locking the main gate and then fled immediately after the shooting,” said a police official, Ahsan Habib.

Two people from nearby villages have been detained for questioning about the attack, another police officer said.

The monitoring service Site said Islamic State had claimed responsibility for the attack, just as it did for the previous bombing on the biggest Shia shrine in the country.

Muslim-majority Bangladesh has seen a rise in Islamist violence in recent months, with two foreigners, four secular writers and a publisher killed this year.

Australia said on Friday that it had given permission to families of government staff posted in Bangladesh to return home, saying there was a threat to Australian and western interests in the country.

The foreign ministry said it planned to withdraw all Australian government-funded volunteers from Bangladesh by 31 December.

“There is reliable information to suggest that militants may be planning to target Australian and western interests in Bangladesh,” the ministry said in a travel advice update on its website. Last month Australia cancelled a cricket tour of Bangladesh, although it played a football qualifier game in Dhaka on 17 November.

This month the US state department also issued a travel alert for Bangladesh, saying there was reliable information that terrorist attacks could occur against foreigners.

Tensions have rising in Bangladesh since the prime minister, Sheikh Hasina, launched a crackdown on militants, putting several leaders on trial for war crimes committed during the 1971 war of independence.

On Thursday police said about a dozen Christian priests in the north had received death threats, a week after an Italian doctor working as a missionary was shot and wounded. “We have already stepped up security around the churches,” the local police chief Abdullah Al Faruk said.

Bangladesh’s government has rejected Islamic State claims of involvement in the attacks and says local militants are involved. Critics say the government is whipping up a climate of fear to go after its political rivals.

Earlier on Thursday, police said they had killed a militant suspected to have masterminded the 24 October attack on the Shia shrine in Dhaka. Police said he was the military chief of a banned underground militant group.