Hamed Sinno, center, the lead singer of the Lebanese band Mashrou’ Leila, performs at the Dubai International Marine Club. (Karim Sahib/AFP/Getty Images)

A crackdown on gay people in Egypt intensified in recent days as security forces raided cafes in downtown Cairo and courts delivered harsh prison sentences, further driving the nation’s LGBT community underground.

More than 60 people have been arrested, human rights activists said, since a concert last month by a rock group where some members of the audience waved a rainbow flag — photos of which went viral on social media and caused public outrage.

Security forces have also detained people at their homes in the middle of the night, and have used apps and online chat rooms to entrap those believed to be gay. Some cafes frequented by the lesbian, gay, bisexual and transgender community have been shut down.

Some of those arrested have endured beatings and other abuse in their prison cells, while others have been subjected to forced anal examinations, human rights activists said.

“The targeting of the community was never on this scale before,” said Doaa Mostafa, a human rights lawyer who is representing a man and woman arrested in the latest crackdown.

Hamed Sinno, left, lead singer of the Lebanese group Mashrou' Leila, and guitarist Firas Abou Fakher read social media posts in Beirut. (Hussein Malla/AP)

The sweeps have unfolded as international human rights activists have denounced the Egyptian government and urged an end to the arrests. On Friday, the United Nations human rights office described the anti-gay raids in Egypt and similar assaults in Azerbaijan and Indonesia as unjust and violations of international law.

As of Tuesday, at least 20 people in Egypt had received prison sentences ranging from six months to six years, the Egyptian Initiative for Personal Rights said, including four people who were sentenced Saturday to three years each.

The crackdown is the latest sign of the repression of political and social freedoms under the government of President Abdel Fatah al-Sissi. Extrajudicial killings by state security forces have soared, say human rights groups, as have arrests of political opponents. Hundreds of websites, including independent media, have been blocked.

Gay rights activists view the suppression of their community as part of an effort to distract from the country’s pressing political and economic woes, including rising costs of living and declining government subsidies, that have fomented anger on the streets.

Targeting the gay community, activists say, appeals to Egypt’s mostly conservative population; both Muslims and Christians consider homosexuality a sin. A 2013 survey by the Pew Research Center found that 95 percent of Egyptians believed that homosexuality was socially unacceptable.

“The rainbow flag incident has made the public furious, and this gave an opportunity for the government and state security to start the arrests,” said Mohamed, an Egyptian gay rights activist who requested that his last name be withheld for security reasons. “They are showing the people that ‘We are conservative. We are embracing our traditions and customs.’ ”

Homosexuality is not illegal in Egypt. But authorities have been targeting gay people under a 1960s anti-prostitution law that contains a clause against “debauchery,” which Egyptian courts have interpreted to include homosexuality.

The latest detentions constitute the biggest action taken against the gay community since the 2001 arrest of 52 people at the Queen Boat, a floating nightclub on the Nile. Over the next three years, an estimated 200 more were arrested, activists said.

Since late 2013, after a military coup led by Sissi ousted the elected Islamist government, an estimated 550 people accused of being gay have been arrested, activists said. More than 250 men have been prosecuted for their perceived sexual orientation, according to the Egyptian Initiative for Personal Rights, whose lawyers are defending those facing trials this month.

The current wave of incarcerations was set off when concert­goers waved a rainbow flag at a performance by Mashrou’ Leila, a Lebanese band with an openly gay frontman. As images spread on Twitter and Facebook, lawmakers, TV personalities and ­religious leaders publicly condemned homosexuality as well as the actions of the concertgoers, further fueling the crackdown.

“The arrests put an end to the defaming of Egypt’s image and its youth,” Mostafa Bakri, a parliament member, told Youm7, a local newspaper. He added that those detained “should be put on an immediate trial because they deliberately aimed to use this event to claim Egypt is a country of homosexuality, and this is not true.”

Some were arrested for waving rainbow flags, and others for their Facebook posts.

“In some cases, individuals were reportedly arrested after being entrapped by law enforcement officials on apps and in Internet chat rooms,” U.N. human rights spokesman Rupert Colville told reporters in Geneva on Friday. “Charges include ‘habitual debauchery,’ ‘inciting indecency and debauchery,’ and ‘joining a banned group.’ ”

Doaa Mostafa, the human rights lawyer, said both of her clients — Ahmed and Sara — are in jail awaiting trial. Sara was arrested this month at her home in the middle of the night. Both had been at the concert, waving rainbow flags.

Security guards ordered other female prisoners to attack Sara in her cell, Mostafa said.

“She was beaten up for one night,” she added.

Egyptian authorities did not respond to requests for comment but have denied allegations by human rights groups of widespread torture by the nation’s security forces in detention facilities.

Activists say that many in their community have left the country in recent weeks — or are considering doing so soon.

“We’re getting lots of messages from people seeking help getting out of the country,” said Mohamed, the activist, who has left Egypt for work and is planning to return only when it is safe. “In the next few months, more people will leave and seek asylum outside Egypt.”

Heba Farouk Mahfouz contributed to this report.