In 2011 when the Arab Spring movement swelled up in Egypt, gay rights groups were buoyed by a sense that the country would soon be riding a wave of social progression. Six years later, Egypt is on the cusp of passing what experts have described as one of the most repressive laws on homosexuality in the world, as police carry out invasive body searches which amount to torture.

The crackdown on those perceived to be homosexual began after two individuals unfurled a rainbow flag - an international symbol of the lesbian, gay, bisexual, trans and queer (LGBTQ) movement - at a concert by the Lebanese rock band Mashrou' Leila, whose singer is openly gay. Following the show on 23 September, the police launched a brutal crackdown, arresting almost 70 people in a month - compared with 300 in the whole of 2016. Over 20 of those have been dealt prison sentences of between six months and six years, Dalia Abdel Hameed of the rights group Egyptian Initiative for Personal Rights (EIPR) told Reuters.

Officials have also subjected detainees to anal examinations, according to Amnesty International. With no medical basis, this practise amounts to torture and therefore breaches international law.

Yet, being gay is not illegal in Egypt. Rather, police are using a 50-year-old prostitution law which bans "debauchery" and "indecency", Mohamed Elmessiry, a human rights lawyer and Egypt researcher at Amnesty International, tells IBTimes UK. Others have detained for apparent links to banned groups that plan to halt the Egyptian constitution, adds Neela Ghoshal, who researchers LGBTI rights issues in Africa for the advocacy group Human Rights Watch.

Although the last time the authorities clamped down so harshly on Egypt's LGBT community was in 2001 - when police arrested 52 men on a floating disco called the Queen Boat - anti-gay rhetoric has been stewing in Egypt since the military coup of 2013, according to Ghoshal. A study by the think-tank Pew Research that year found that 95 per cent of people in Egypt believed that homosexuality should be rejected.

"We have never seen anything of this magnitude before in terms of arrests," continues Ghoshal. "It's really shocking. It's almost unlike anything we've seen in the world in terms of the crackdown, considering the resources devoted to it and the accusations being levied."

The concert, a rare instance of a rainbow flag being waved in public, sparked what Rashima Kwatra of the LGBT rights group OutRight Action International, described to IBTimes UK as society-wide "moral panic" .

Mashrou' Leila show in Lebanon
A fan of Lebanese alternative rock band Mashrou' Leila holds a rainbow flag during their concert in Lebanon in August. A similar act in Egypt sparked a tough anti-gay crackdown. REUTERS/Jamal Saidi/File Photo

Prime-time TV host Ahmed Moussa declared homosexuality as as "terrible as terrorism". Days later, Egypt's media regulatory body labelled homosexuality as a "sickness and disgrace" and banned coverage deemed pro-LGBT: announcing that only those repenting their sexuality could appear in broadcasts. The Coptic Christian church is meanwhile reportedly set to host a conference entitled the"Volcano of Homosexuality" to discuss "cures" and ways to combat same sex relationships, says human rights lawyer human rights barrister Gemma Lindfield.

Allies are also under attack. Poet Mohsen al-Balasy was ejected from the set of al-Mehwar TV after being one of the few to publicly defend LGBT people. And Mashrou' Leila, and their singer Hamed Sinno - one of the only openly gay musicians in the region - have been banned from Egypt, according to Syndicate of Musical Professions.

Riding on the momentum of the response to the show, a group of 15 MPs lead by Riad Abdel have presented the Speaker of the Egyptian House with a draft law that would criminalise every aspect of LGBT life. Same-sex relations could become punishable by up to 15 years in prison. Allies and those who organise or participate in what are seen as pro-LGBT events could face three years in jail, according to the AlBawaba news website.

"If passed, it could potentially be one of the worst laws on the books against LGBTIQ people anywhere," says Kwatra.

Police are meanwhile allegedly trawling social media and dating apps including Grindrand Hornet to target individuals, prompting the firms to send warnings to their users in Arabic. To prevent attacks and raids, Grindr has offered safety tips on meeting potential partners, avoiding police entrapment, and information on how to access local LGBT resources and organisations.

"We encourage our users in this region to read the safety messages we put out daily on our app written in Arabic," Peter Sloterdyk, vice president of marketing at Grindr, told IBTimes UK. "These messages are developed in partnership with local LGBT activists and are designed to avoid creating panic while sharing information that can help keep our users safe."

It is very possible that this law will pass. The public appear to be heeding the message.

"There is a big LGBT movement in Egypt, which became particularly significant after the Arab Spring," explains Ghoshal. "It galvanised people into activism and LGBT people who hadn't seen hope were inspired that the voice of the people could make a difference, although the revolution didn't succeed. They saw there was scope for people to stand up for their rights.

"Most of these groups operate entirely underground so they may have a Facebook page and events but very carefully screen who attend. And people don't use their real names on Facebook or other forums where they discuss rights."

Activists protest against gay arrests in Egypt
Protestors march near the Egyptian consulate in New York on August 15, 2001 carrying signs critical of the Egyptian government's detention of 52 allegedly gay men. PM/TRA

However, social media accounts Rainbow Egypt, Solidarity with LGBTQ Egypt, and the Egyptian Initiative for Personal Rights have all become more cautious in the wake of the arrests, adds Ghoshal.

And the danger of infiltration of such organisations and apps also serves to "create an environment of complete and total distrust within a community", Kwatra warns. "This is a tactic the Egyptian government has used in the past and continues to exploit in this current crackdown on people who are actually or are perceived to be LGBTIQ."

Experts are currently split over whether the proposed anti-gay laws will be rubber stamped by the Egyptian Parliament.

"This law is aimed at the conservative factions in society," comments Lindfield. "Outrage in respect of the LGBT community serves to detract from other more pressing issues in society. In light of the frequent public comments and discriminatory acts of Egyptian public institutions, it is very possible that this law will pass. The public appear to be heeding the message," she adds.

The consequences of such a bill would be devastating

In contrast, Ghoshal says activists are uncertain how seriously to take the bill. "There are a lot of laws that don't go anywhere. It depends if they have backing and that remains to be seen. But law has been proposed that is quite harsh, and we hope it will melt away. Of course there is a risk that it could go forward, with increased sentences for so -called repeat offenders. And if you are gay your sexuality is part of your identity so of course you will be a 'repeat offender'."

"The consequences of such a bill would be devastating," warns Kwatra. "We've seen these types of bills pass or try to pass elsewhere and we know that these laws increase violence and discrimination against LGBTIQ people, run them underground, impact their health and wellbeing, and even cause many to flee and seek refuge elsewhere."

Whether or not the law sees the light of day, the clampdown shows no sign of slowing despite being in breach of international law and the Revised Arab Chart on Human Rights (which Egypt has signed but not ratified) that emphasises the rights of citizens to dignity.

"There are two bases on which criminalisation of homosexuality is in breach of the UN's International Covenant on Civil and Political Rights (ICCPR) and The Convention Against Torture (UNCAT) ," explains Lindfield. "Firstly, that targeting a specific group on account of an immutable characteristic is in itself inhuman and degrading treatment. Such laws criminalise a person's identity.

"Secondly, and this is relevant to what we are seeing in Egypt and in many other countries in the world, the laws provide a licence for acts that may amount to inhuman and degrading treatment," she says, pointing towards reports of anal examinations in police custody. "

"It is also worth remembering that there is a duty on the state to prevent inhuman and degrading treatment. An example would be the widespread use of 'corrective rape' of gay and lesbian people. If the state knows that this is a problem then it is under a duty to protect those individuals."

Kwatra argues that the clampdown is a tactic to distract from the nation's failing economy which has been pinned on Abdel-Fattah el-Sisi, the former general who seized power from an elected Islamist government in 2013. "These types of laws are often used to target LGBTIQ people, and others who are deemed less than, and incite fear among the community.

"Egypt, under Sisi, has a history of using such laws to persecute LGBTIQ people, mainly gay men. Pitting the public against LGBTIQ people has been an easy scapegoat for many governments to pivot attention away from the actual problems in a country. It is easier to get mad at the gays than it is to actually fix what is broken."