The Bangladeshi branch of Al Qaeda claimed responsibility Tuesday for the killing of a gay rights activist and his friend, undermining the prime minister's insistence just hours earlier that her political opponents were to blame for the attack and for a rising tide of violence against secular activists and writers.

The claim by Ansar-al-islam — which said it targeted the two men on Monday night because they were "pioneers of practicing and promoting homosexuality" — raised doubts about Prime Minister Sheikh Hasina's repeated assurances that authorities have the security situation under control.

The victims of the attack were identified as Xulhaz Mannan, an activist who also worked for the U.S. Agency for International Development, and his friend, theater actor Tanay Majumder. Mannan, a cousin of former Foreign Minister Dipu Moni of the governing party, was also an editor of Bangladesh's first gay rights magazine, Roopbaan. Majumder sometimes helped with the publishing, local media said.

At a funeral for Mannan on Tuesday, his brother said free speech was something Islam should protect.

"A true Muslim will always consider that he has freedom of expression," Minhaz Mannan Emon said. "We should respect that opinion. We hope... particularly I, on behalf of the family, hope that no other family loses their child or brother like us in the future."

Mannan had written openly about the frustration of living "in the closet" as a gay man in Bangladesh, where homosexual relations are considered a crime. In a May 2014 blog, he said gays and lesbians in Bangladesh experience "A country where the predominant religions say you are a sinner, the law of the land says you are a criminal, the social norms say you are a pervert, the culture considers you as imported."

He launched the magazine in 2014, giving the country's small and secretive lesbian, gay, bisexual and transgender community its first open platform. Earlier this month, he tried to organize a Rainbow Rally in the capital, but was foiled when police briefly detained him and three others.

Ansar-al Islam, the Bangladeshi branch of Al Qaeda on the Indian subcontinent, or AQIS, claimed responsibility in a Twitter message on Tuesday for what it called a "blessed attack" on Mannan and Majumder.

It said the two were killed because they were "pioneers of practicing and promoting homosexuality in Bangladesh" and were "working day and night to promote homosexuality ... with the help of their masters, the U.S. crusaders and its Indian allies."

Just hours before the claim of responsibility, the prime minister had pointed the finger at her political opponents, the fundamentalist Jamaat-e-Islami group and its ally, the opposition Bangladesh Nationalist Party.

"Everybody knows who are behind these killings," Hasina told policymakers in her secular Awami League party Monday night, repeating her government's allegation that the opposition was orchestrating the attacks. "The BNP-Jamaat clique has been involved in such secret and heinous murders to destabilize the country."

The opposition denies the allegations, saying they are being scapegoated for Hasina's failure to maintain security and placate the country's desire for Islamic rule.

Police said no arrests have yet been made in connection with Monday's attack, which involved at least five young men who posed as courier service employees to gain access to Mannan's apartment building.

A security guard working at the building said he was injured when one of the attackers hit him with a knife while fleeing.

Crime scene investigators recovered a mobile phone and bag apparently left by the attackers. The national police chief, A.K.M. Shahidul Hoque, expressed confidence the attackers would be caught and acknowledged there were similarities in how the killings were being carried out. He said authorities were making progress in cracking down on radicals' hideouts and weapons caches.

"We are investigating all the cases very seriously," Hoque said. "Many arrests have been made involving previous killings, we have busted their dens for making bombs."

Security analysts warned that the government could lose the people's trust if it does not act quickly to curb the attacks.

"It is high time to set up special tribunals to handle these cases," suggested retired Maj. Gen. Abdur Rashid. "It has to be dealt with more seriously and with a clearer and quicker process. ... There has been a lack of confidence among people about the investigation and justice system. We must fix these issues immediately."

U.S. Secretary of State John Kerry condemned the "barbaric" murders in a statement. Earlier this month, the U.S. said it was considering granting refuge to a select number of secular bloggers in Bangladesh facing imminent danger.

State Department spokesman John Kirby said Monday that remained an option. He described Mannan as a "beloved member of our embassy family and a courageous advocate" for gay rights, and pledged U.S. support to Bangladeshi authorities "to ensure that the cowards who did this are held accountable."