The Rapid Action Battalion (RAB), the elite security force that conducted the raid, said it had arrested the men from a community centre south of the capital Dhaka for "homosexuality", although they were later charged with drug offenses instead.
"We've arrested 27 people for homosexuality. They are homosexuals. They held a get-together there," said Major Manzur of the RAB, who asked to be identified only by his rank and given name.
However, they were later transferred to the custody of the regular police where they were charged with drugs-related crimes.
Gay rights activist among two hacked to death in Bangladesh
"We have filed a narcotics case against them as the RAB found Yaba (methamphetamine) and marijuana among their possessions," local police chief Mohammad Jubayer said.
Gays and lesbians in Bangladesh frequently suffer discrimination and other rights abuses and many are forced to hide their sexual identity and live double lives for fear of reprisals.
Bangladesh criminalises gay sex under a law dating back to the British colonial era that has never been repealed but is rarely enforced.
Last year two prominent LGBT activists including an editor of the country's only magazine for gay people were hacked to death by extremists linked to al Qaeda.
Many prominent homosexual activists have since fled the country after several of them received death threats.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ