Addressing a crowd of thousands filling San Francisco’s Harvey Milk Plaza to honor the victims of a gun massacre at a gay nightclub in Orlando, Supervisor David Campos said the violence highlighted the urgency of continuing the fight for LGBT rights.

But Campos had another message.

“We are all in this together,” he said, “and as a queer Latino man I know that targeting the Muslim community in the way some people are doing is simply wrong and we are going to speak out against it!”

People in the crowd on Sunday night, many holding candles in plastic cups as the neighborhood’s giant Pride flag flew at half-staff, roared in support. And in the ensuing days, LGBT community leaders have made a point to say the shooting should not be used to demonize the Muslim community, as they embraced an affinity between two groups that have faced persecution.

The mass murder, in which a man who pledged allegiance to the Islamic State gunned down 49 club-goers before being killed by police, has again raised questions about how the U.S. can stop terrorists within its borders who radicalize themselves, and how the country can stop the bloodshed from gun rampages in recent years that have hit schools, entertainment venues and workplaces.

Trump attacks Clinton

But it also prompted Donald Trump, the presumptive GOP presidential nominee, to seek to divide LGBT Americans and Muslim Americans, as he attacked presumptive Democratic nominee Hillary Clinton.

Trump, who wants to bar all Muslims from immigrating to the U.S., tweeted Tuesday, “Thank you to the LGBT community! I will fight for you while Hillary brings in more people that will threaten your freedoms and beliefs.”

San Francisco Supervisor Scott Wiener, who is gay, said such responses were distortions of a tragedy that carries real implications for lesbian, gay, bisexual and transgender people.

“He targeted an LGBT nightclub in order to massacre gay people,” Wiener said of gunman Omar Mateen, “and we need to not let the Donald Trumps of the world hijack this attack to further their racist and Islamophobic agenda.”

Campos said the LGBT community, having been scapegoated in the past, recognizes the danger Muslim Americans face in the aftermath of the shooting.

“I think it comes from the fact that we have been through this before,” he said. “We have seen this movie before, and we’re not going to let people like Donald Trump take advantage of it.”

Federal authorities Tuesday were looking into Mateen’s motives and scrutinizing his past statements about terrorist groups and gay people. A hostage who survived the attack on the Pulse nightclub described at a news conference how Mateen, the New York-born son of Afghan immigrants, had called 911 amid the carnage and said he wanted “Americans to stop bombing his country.”

But the portrait of Mateen was complicated by reports that he had been a frequent visitor of the club and had used dating apps for gay men.

Messages of support

As the investigation continued, those in the Muslim community said the messages of support from LGBT leaders were touching. Suzanne Barakat, a resident physician at San Francisco General Hospital whose brother was one of three young Americans Muslims shot to death last year in North Carolina, allegedly by a neighbor, also spoke to the crowd in the Castro on Sunday night.

“I felt connected to everyone at the vigil when I heard leaders from the LGBT community say they wouldn’t let the shooting be used to attack Muslims,” she said. “I wanted to let my community, the people of San Francisco, know that we are one body, that I stood with them, that people who identify as Muslim stand with people who identify as LGBTQ against the dark tide of hate.”

A 2014 Pew Research Center poll found that 45 percent of U.S. Muslims believed homosexuality should be accepted by society — a seven-point increase from 2007. The mark was 62 percent for all poll respondents, and 55 percent for those affiliated with religions. Thirty-six percent of evangelical Christians and Mormons believed homosexuality should be accepted.

On Monday, Zahra Billoo, head of the Bay Area chapter of the Council on American Islamic Relations, joined a group of politicians and advocates including Rebecca Rolfe, director of the San Francisco LGBT Center, at a news conference urging a different response to the massacre — passage of a slate of California gun control bills.

“It’s been really humbling that a community that is targeted and under siege and still processing the attack has been so thoughtful about being clear they would not let this attack be used to fuel Islamophobia,” Billoo said. “I think that is so powerful and how I’d want to be if I were under attack.”

Six months ago, Rolfe reached out to Billoo after her organization’s offices were shut down due to an anthrax scare, and offered to allow the organization to work from there.

“The problem is homophobia and not Muslims,” Rolfe said. “Many LGBT are Muslims and we have literally millions of allies who are Muslims, and to misdirect our anger and our fear leaves us vulnerable to where the danger actually is.”

After Trump’s fiery speech Monday, national LGBT leaders were quick to push back.

“LGBTQ people, we are Muslims, we are women, we are Latinos,” Chad Griffin, president of the Human Rights Campaign, said on CNN. “We are as diverse as the fabric of this nation, and any attack on any one of us is an attack on all of us.”

‘Attempt to divide’

The Human Rights Campaign’s communications director, Jay Brown, said in an interview that Trump’s comments were a “shameless attempt to divide us. We will not allow an act rooted in hatred against LGBTQ people to be used to promote hatred against Muslim people.”

Speaking at the vigil in San Francisco, Barakat offered a similar message to the crowd.

“Tragedies are coming to us far too frequently — the cure for it is the medicine of love, kindness and compassion,” she said. “We stand here to extend our shared humanity and everlasting love and say to those consumed by hatred you will not define us, you will not mold us in your image, you will not sow the seeds of discord among us, you will not deter us in our determination to treat all with dignity.”

Hamed Aleaziz is a San Francisco Chronicle staff writer. Email: haleaziz@sfchronicle.com Twitter: haleaziz