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

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

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

They entered the apartment disguised as couriers, he said, quoting witnesses.

They 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. U.S. Ambassador Marcia Bernicat condemned the killings.

"We abhor this senseless act of violence and urge the government of Bangladesh in the strongest terms to apprehend the criminals behind these murders," she said.

Other attacks by Islamic militants took place in the country Monday, but it was not immediately clear whether those assaults were carried out.

Two men on a motorcycle shot dead a former prison guard in front of Kashimpur jail, on the outskirts of Dhaka, Khandakar Rezaul Hasan, chief of the local police station, said.

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 of last year.

A group affiliated with al Qaeda claimed responsibility for the killing of a liberal Bangladeshi blogger this month.

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

The government has denied that the Islamic State group, also known as ISIS, or al Qaeda organizations have a presence in the country and said homegrown Islamic 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 Islamic militants looking to establish a Sharia-based Muslim state.