A woman holds rainbow flag as Turkish anti-riot police fire rubber bullets to disperse demonstrators gathered for a rally staged by the LGBT community in Istanbul on June 19. (Ozan Kose/AFP/Getty Images)

It was just after sunset when patrons began to arrive, climbing a dark stairwell to the bar’s modest entrance. Here, in dimly lit corners, is where the mostly gay clientele come to canoodle and drink — but without the threat of violence or harassment.

Turkey, with more than 74 million people, is one of 20 Muslim-majority countries where homosexuality is technically legal. And cosmopolitan Istanbul, the country’s largest city, is a hub for gay and transgender life.

But conservative attitudes and a repressive government mean many gay Turks are still subject to persecution. And after the massacre at a gay nightclub in the United States this month, members of the LGBT community here say they feel especially vulnerable to attack.

On Friday, the organizers of Istanbul’s annual gay-pride parade announced that they would not be holding the march that was scheduled for Sunday, after officials refused to grant them permission, citing security concerns.

But the government’s decision also drew accusations of discrimination, and organizers said this is the first year since 2003 that a gay-pride march will not take place. LGBT activists say the threat from extremists is real but also accuse the Islamist-led government of canceling the parade in a bid to silence dissent.

Turkish nationalists burn a rainbow flag during a rally staged by the LGBT community in Istanbul on June 19. (Ozan Kose/AFP/Getty Images)

“The ban on Pride March is an effort not only to stop us from leading dignified lives, but also stop us from dreaming of this world” where people’s differences are respected, the Istanbul LGBTI+ (Lesbian, Gay, Bisexual,Transgender, and Intersex) Pride Week Committee said in its statement Friday. The government “has chosen to violate [the laws] guaranteed by the Constitution,” the committee said, “instead of protecting us against the threats that it has put forth as grounds for the ban.”

Homosexual activity has been legal in Turkey since the modern republic’s founding in 1923, but there are no laws that protect gay and transgender Turks from discrimination. And Turkish officials routinely use “homophobic and transphobic rhetoric” in speeches, Amnesty International said in a statement this month.

Attacks on LGBT individuals — including killings — are often ignored or only lightly investigated, activists say. Courts also regularly reduce or suspend the sentences of criminals convicted of these assaults.

In Turkey, if you are gay or transgender, “there is no support from the state. The government is against you because they don’t like people who are different,” said Levent Piskin, an Istanbul-based lawyer and gay rights activist.

“The government should be there to protect us from threats, but instead they have made targets out of us,” Piskin said.“Turkey is not a safe place for the LGBT community.”

But it wasn’t always like this, activists say. And in the past two decades, a growing LGBT community has pushed for and gained wider acceptance.

The state of gay rights around the world

Istanbul held its first gay-pride parade in 2003, an event that — unprecedented in the Muslim world — gradually grew to include tens of thousands of participants.

The country’s Supreme Court ruled in 2014 that referring to homosexuals as “perverts” constitutes hate speech. Gay and transgender candidates have successfully run for political office.

Transgender women have also made strides in the entertainment industry, including Bulent Ersoy, a singer who is a staunch supporter of Turkish President Recep Tayyip Erdogan. Fatih Urek is a 60-year-old male pop star who wears heavy makeup and feminine outfits and is popular among mainstream Turks.

But outside of elite Turkish ­society and the trendy Istanbul quarters where homosexual and transgender Turks live somewhat comfortably, life remains difficult for the LGBT population.

Local rights groups documented more than 40 “hate murders” against LGBT individuals between 2010 and 2014, according to a report submitted to the United Nations. And a 2013 poll by the Pew Research Center found that 78 percent of Turks do not think homosexuality “should be accepted by society.”

Activists fear that the climate is getting worse as authorities move to silence critics of all stripes.

Last year, for the first time, police attacked the Istanbul pride parade with rubber bullets and tear gas, after officials refused to authorize the march. Many LGBT activists think the parade was canceled because it was scheduled to take place during the ­Islamic holy month of Ramadan, when Muslims fast from sunrise to sunset, and in a concession to the country’s conservatives.

A week ago, when transgender activists held their own Trans Pride march, the police also dispersed the demonstrators with tear gas. Several days later, authorities announced that they had arrested three suspected Islamic State militants they said were plotting to attack the parade.

On Thursday, authorities denied event organizers permission to hold even a news conference in lieu of the parade, “due to the terror attacks that have taken place in our country and the area,” according to the statement from Istanbul’s deputy governor.

“It may cause a disruption in public order and the people’s . . . tranquility, safety and welfare,” said Nurullah Naci Kalkanci, the deputy governor.

“They use Ramadan as an excuse,” Ebru Kiranci, a transgender activist and president of the Istanbul LGBTI+ Solidarity Association, which works specifically on transgender rights, said about the government.

But “they don’t want the trans and lesbian and gay communities to be seen in society,” she said.

At the secluded gay bar in Istanbul, Cemal, the manager, says the parade should be postponed until after Ramadan. That way, he says, there won’t be any confrontation.

“People will react in a certain way” if it’s Ramadan, says Cemal, who is gay and maintains to his Muslim faith.

His father, a Muslim preacher, doesn’t know that he is gay. Neither do the rest of his relatives, who live in Turkey’s conservative eastern countryside. “They would kill me,” Cemal, who asks that his full name not be used, says of his family. He puts his finger to his head, pretending to have a gun. “Bang! Bang!” he says, laughing.

Cemal then quiets down.

“If God created me this way, then why should I oppose it?” he says. Or, if God created him this way, he continued, “why should I stop believing in God?”

Zeynep Karatas contributed to this report.