Suspected Islamist militants hacked to death a leading gay rights activist and a friend in an apartment in the Bangladeshi capital on Monday, police said.

The killings took place two days after a university professor was slain in similar fashion on Saturday in an attack claimed by Islamic State.

Five or six assailants went to the apartment of Xulhaz Mannan, 35, an editor of Rupban, Bangladesh's first magazine for gay, bisexual and transgender people, and attacked him and a friend with sharp weapons, Dhaka city police spokesman Maruf Hossain Sordar said.

Xulhaz Mannan (left) with a US embassy official | Source: Facebook| Xulhaz Mannan

They entered the apartment disguised as couriers, he said, quoting witnesses. The assailants also wounded a security guard. Witnesses said the attackers shouted "Allahu Akbar" ("God is greatest)" as they fled the scene. Mannan previously worked at the U.S. Embassy in Dhaka.

"We are outraged by the barbaric attack on Mr. Xulhaz Mannan, a beloved member of our embassy family and a courageous advocate for LGBTI rights, human rights, actually," U.S. State Department spokesman John Kirby told reporters in Washington. "LGBTI" stands for lesbian, gay, bisexual and intersex.

Other attacks took place in the country on Monday, but it was not immediately clear whether those assaults were carried out by Islamist militants. Two men on a motorcycle shot dead a former prison guard in front of Kashimpur jail, on the outskirts of Dhaka, said Khandakar Rezaul Hasan, chief of the local police station. A teacher was hacked to death in the southwestern district of Kustia, police said.

The Muslim-majority nation of 160 million people has seen a surge in violent attacks over the past few months in which liberal activists, members of minority Muslim sects and other religious groups have been targeted.

Five secular bloggers and a publisher have been hacked to death in Bangladesh since February 2015. A group affiliated with al Qaeda claimed responsibility for the killing of a liberal Bangladeshi blogger this month.

Islamic State has also claimed responsibility for the killings of two foreigners and attacks on mosques and Christian priests in Bangladesh since September.

The government has denied that Islamic State or al Qaeda groups have a presence in the country and said homegrown Islamist radicals are behind the attacks. At least five militants have been killed in shootouts since November as security forces have stepped up a crackdown on Islamist militants looking to establish a sharia-based Muslim state.

(Feature image source: Twitter| Michael De Gora)