Pop star Katy Perry’s “I Kissed a Girl” was playing on speakers set around the dimly lit dance floor. Kholoud Bidak, a 33-year-old lesbian, leaned against an old piano, scanning the entrance warily as guests paid $6 to get into one of Cairo’s increasingly common underground gay parties.

Just months ago, a raid by Egypt’s vice police would have been a concern at gatherings such as this fete for a man in red shorts who was turning 26. But on the recent sweltering Thursday night, as men in pastel-colored, V-neck T-shirts streamed in, a crackdown was the last thing on Bidak’s mind. She worried whether a certain woman might walk through the door.

Bidak doesn’t have a girlfriend. “I have drama,” she said.

Egypt’s gays emerged buoyed from the uprising that toppled President Hosni Mubarak in February. Increasingly visible and willing to speak up, they show how upheavals across the Arab world could prove to be social and cultural revolutions, albeit with uncertain outcomes.

Could Egyptian gays emerge as the pioneers of social liberalization in a region where a wave of revolts has forced out autocrats and raised the prospect that largely youth-led movements could upend dogmatic mores? Or in the months ahead, might gays and other liberal groups lose out against a rise of fundamental Islamists — another long-oppressed segment of society empowered by revolution?

Here in Egypt, gays and lesbians have turned a handful of public venues into spaces where it’s safe for men to dance with men and where women sit on each other’s laps. And activists are quietly putting together campaigns they hope will enable gays and lesbians to live openly in a country where sexual minorities have long been ostracized.

Web sites used to meet gay men are once again wildly popular because police appear to have ceased using them to conduct sting operations. Some people have gone as far as creating an anonymous Facebook page with a provocative goal: “A Gay Pride March for Egypt in 2020.”

Most of the revelers at this second-story venue, tucked behind the courtyard of a decaying downtown building, were in their 20s and 30s. They tossed back bottles of $3 Egyptian Stella beer and glasses of lukewarm red wine. A DJ alternated between pop hits — lots of Lady Gaga — and songs in Arabic.

Scott Long, an American human rights researcher who has studied Egypt’s gay community for years, watched in amazement as hips swung on the wooden dance floor. 

“For me, it’s an astonishing thing to come here and find that there is a community,” said Long, 48.

A community upended

A similar community had begun to take root in the late 1990s in Cairo at a handful of bars, including one at the Ramses Hilton hotel. The Queen Boat, a nightclub that operated out of a docked, vessel-shaped venue on the Nile River and named after the last queen of Egypt, was a favorite meeting point.

But in May 2001, vice officers raided the disco — spurred, Long said, by a war of words between the Mubaraks and a rival political family, the Sadats, who offended the president by suggesting a prominent relative of his was gay.

Over the next few months, Egyptian newspapers portrayed the backlash as a crackdown on a cult of devil-worshipers. Vice officers created fake profiles on gay Web sites and set up meetings with men looking for dates.

“People would just disappear,” Long said.

Gehad, 27, a gay rights activist who asked to be identified only by his first name, remembers going to a court hearing for a Queen Boat defendant.

“I saw grown men hiding their faces with tissues,” he recalled. “Spectators were throwing plastic cups at them.”

Like most Egyptian gay men at the time, Gehad went underground.

The intensity of the crackdown eased somewhat after Human Rights Watch released a report in 2004 titled “In a Time of Torture.”

Prosecutions continued intermittently, largely under the radar, until 2007, when two HIV-positive gay men were taken into custody in Cairo’s Tahrir Square.

Egyptian media reported extensively on the case, saying police had broken up a vast network of perverts with a dangerous disease. The reports included names, occupations and ages. The two men served 27 months in custody, during which they were subjected to insults and beatings, according to one of the two, Ahmed, who also asked to be identified only by his first name.

‘Useful for us to be visible’

When Egyptians began battling police in late January, Ahmed was excited.

“We thought there would soon be more freedom,” he said.

On Jan. 25, the day the demonstrations began, Bidak remembers spotting a large group of young gay men with tweaked eyebrows, shiny lip gloss and skinny jeans among the protesters. The next time she saw them, on Jan. 28, the day security forces cracked down most violently on the revolt, the men had ditched the glam and braced for battle, carrying vinegar and onions to make the sting of tear gas bearable.

“I think being queer played a huge part,” she said about their motivation to protest. “It was useful for us to be visible and prove that we’re here, that we’re human beings, that we do exist. You can see us.”

Bidak said she spent several days fighting alongside bearded members of the Muslim Brotherhood. As she perfected the art of assembling molotov cocktails using plastic bottles, some of her comrades didn’t realize she was a woman.

Days after Mubarak’s Feb. 11 ouster, Egyptian women expressed hope for greater rights. Fundamentalist Muslims started plotting a political comeback. Coptic Christians spoke of a more visible role in society.

Although gays celebrated largely in silence, many began feeling somewhat empowered. Bidak used to wear headphones and stared at the ground as she walked to tune out the jeers that followed her.

“Now it feels easier to have a voice,” she said. “Now I make eye contact.”

But for Bidak and many other Egyptian gays, the enthusiasm has fizzled. Islamists, all but certain to become politically powerful in the coming elections, have been calling for a strict religious state; dogmatic politicians have been ascendant in Tunisia, which is among the most liberal of Arab nations.

Meanwhile, Egypt’s security forces, now run by military chiefs, are resorting to tactics the old regime used to silence critics.

In a narrow downtown Cairo street lined with cafes with outdoor seating, the owner of an establishment frequented by young gay men recently called the army to complain about how ostentatious his clientele had become. After gay patrons balked at paying a new $12 cover charge — which they interpreted as discriminatory — soldiers moved in to try to eject them, said Gehad, the activist, who witnessed the scene.

Female friends sitting with the gay men formed a protective circle around them.

“The girls surrounded the queers and said: ‘If you want to take them, you need to attack us first,’­ ” he said.

The soldiers walked away. The cover charge was never brought up again.