“What is happening now is unprecedented,” said Gasser Abed El Razek, executive director of the Egyptian Initiative for Personal Rights, which has been monitoring the crackdown and providing legal aid to defendants. “We think they are doing this to respond to the fuss that the Mashrou’ Leila concert created.”

At least one recent detainee has been convicted, according to state media, which did not identify the person. It said the detainee had been sentenced last week to six years in prison for “committing debauchery.”

Most of the 34 people arrested since the concert were ensnared through social media and dating apps, prosecutors said. Egyptian authorities have long used online entrapment to arrest gay people, including during a crackdown in 2001. Officers lure someone to a date, arrest them and then use the messages sent during their flirtation as evidence in court.

One prosecution official, who spoke on condition of anonymity because he was not authorized to speak to reporters, said the existence of such apps and websites — and their increased use in Egypt in recent years — had made arrests and prosecutions much easier.

In an interview on Tuesday at the Giza courthouse, where five men suspected of being gay were on trial in a separate, older case, the official described the internet as teeming with gay people.

He said the police had not decided to start rounding up gay people but simply had gone online and kept encountering them. If gay people stopped using the internet to meet each other, they would stop getting arrested, he said.

Members of Mashrou’ Leila, who are currently artists in residence at New York University’s Hagop Kevorkian Center for Near Eastern Studies, said through a spokeswoman, Hind Azennar, that they were “heartbroken that the band’s work has been used to scapegoat yet another crackdown by the government.”