(CNN)In 2017, Sarah Hegazi was arrested and said she was tortured for waving a rainbow gay pride flag at a concert in Cairo. Last weekend, the 30-year-old died by suicide in Canada.
Hegazi's friends reported her death, circulated a suicide note and shared an outpouring of messages of solidarity, grief and anger. Their mourning was soon hijacked by hateful messages.
On social media, posts about Hegazi that ended with the traditional condolences, "May God Have Mercy on her," were followed by comments saying "she is not worthy of His Mercy," and a torrent of expletives targeting her sexuality.
These bitter exchanges echoed a long-running clash between Egyptian progressives and conservatives that haunted Hegazi's life. She was a software developer, a "feminist, interested in politics and a queer activist," fellow LGBTQ activist and friend Malak Elkashif told CNN from Cairo.
By waving the flag, Hegazi became an icon for the gay community and a target for state violence.
Analysts say that Egypt's government often enforces conservative values by imprisoning, torturing and silencing women, members of the LGBTQ community and other citizens who don't conform to its social norms.
Earlier this year, Egypt told the UN Human Rights Council it has "vowed to safeguard human rights, ensuring equal rights and opportunities to all citizens without discrimination," and it has "thoroughly" investigated all "individual" cases of torture.
After conservatives criticized and filed complaints against two women for posting dancing and lip synching videos on TikTok that got hundreds of thousands of views, authorities last week charged them with the vaguely worded crime of "violating family principles and values."
"The regime uses its tools -- such as the media, and mosques -- to tell Egyptian society, which is understood to be 'religious by nature': We too protect religion and social morality, so there is no need for Islamists to compete with us!" Hegazi wrote in an article published by local independent platform Mada Masr in 2018.
The Egyptian state and the proponents of political Islam had put aside their long-running animosity, agreeing on using hate and prejudice to curb individual freedoms, she argued. Her writings weaved political critique into her struggle as an openly gay woman.
When Hegazi and her friends raised the rainbow flag at the September 2017 concert by Mashrou' Leila, a Lebanese band with an openly gay frontman, she was hailed by allies for "breaking many barriers of silence," said her friend Tarek Salama.
"To see someone who publicly say they are leftist, that they are against state violence and that they are queer, made me worried about her. But I was also fascinated and humbled," Salama told CNN.
Photos of the colorful flag fluttering under the spotlights enraged talk show hosts and newspaper columnists. Days later, Hegazi and her friends were arrested. Police ultimately detained at least 75 people in the month following the concert in what one Egyptian rights group called an "unprecedented upsurge in security crackdown targeting gay and transgender citizens or those believed to be so."
Sixteen years prior, in 2001, a similar crackdown took place. In what was known as the Queen Boat case, police arrested dozens of men in Cairo and charged them with "habitual debauchery" -- a legal term used to prosecute LGBTQ people. The men hid their faces during the public trial in fear of recognition, and reported a life ruined by the torture, shame and stigma.
What set Hegazi's experience apart was her willingness to show her face despite the backlash.
"It was a day to mark in history as the start of the liberation of the LGBTQ community in Egypt," Elkashif said.
Hegazi remained in detention for three months. She said she was tortured by electrocution and subjected to sexual harassment by female prisoners acting on the orders of officers "who believed she had to be punished," she wrote on Daaarb.com, an electronic publication of the Socialist Popular Alliance Party.
Egyptian authorities have repeatedly denied claims of systematic torture in prisons and did not respond to Hegazi's claims. The government didn't immediately respond to CNN's request for comment.
During interrogation at the state security prosecution, which usually handles terrorism and high profile political cases, Hegazi would clutch her lawyers' arms and beg them not to let her go back to detention, her lawyer and friend Mostafa Fouad told CNN. In hours of questioning, police probed into the details of her life, she later wrote. They asked her why she took off the Islamic headscarf, which she had previously donned, and if she was a virgin.
She was charged with "promoting debauchery" and with joining an illegal organization that "threatens public and societal peace," a charge usually leveled against Islamists and political dissidents, according to Fouad.
Hegazi was released pending trial to find that her family and her neighbors had rejected her and she was fired from her job. Society "welcomed" what happened to her, she wrote in Daaarb.com last March.
"The Egyptian middle class leans towards the socially and religiously conservative right. It supports state decisions to impose guardianship on the society ... they practice social stigma [against anyone who] revolts against this oppressive patriarchal culture that is based on oppressing women, workers, and religi