A man lights a candle as people gather outside of the Stonewall Inn in New York as a vigil is held following the massacre that occurred at a gay Orlando nightclub on Sunday. (Monika Graff/Getty Images)

On Thursday, scores of gay, lesbian, bisexual and transgender Americans lined up in the glorious sunshine outside the southeast entrance to the White House for the president’s eighth annual “celebration of LGBT Pride Month.”

You have just read one of hundreds of sentences I never expected to be able to write, four decades after I realized that I was gay.

And here is the sentence I never wanted to write — about 50 people being massacred in a gay club, the worst mass shooting in U.S. history. In the United States, almost every step forward for gay people has been followed by several steps backward.

But Sunday’s horror exceeds anything many people have experienced before — except for those of us old enough to remember the mass casualties of the AIDS epidemic. That catastrophe wiped out one-half of the gay men of my generation.

On the eve of that epidemic, a similar though much smaller shooting spree sent a wave of fear through Manhattan’s Greenwich Village, quite like the one felt in Orlando early Sunday. In November 1980, a former New York City transit police officer stole an Uzi and three other weapons. Then he fired into a Village bar and two other locations, killing two and wounding six.

On days like this, it is especially important to remember that we are a battle-hardened movement.

Indeed, Thursday’s White House celebration came 51 years after Washington saw the very first people ever to identify themselves as gay outside the White House. Twelve picketers led by Washington gay leaders Jack Nichols and Frank Kameny startled bystanders with handwritten signs reading “15 Million Homosexuals Protest Federal Treatment.”

They were referring to the executive order signed by Dwight Eisenhower in 1953 that prohibited the federal government and all of its contractors from employing anyone who was known to be gay — a policy backed even by the American Civil Liberties Union in the 1950s.

Five decades later, we had the run of the second floor of the White House with champagne and smoked salmon and the company of Eric Fanning, the openly gay secretary of the Army. There too were openly gay legislators, such as Rep. Sean Patrick Maloney of New York and former senator Harris Wofford of Pennsylvania, as well as powerful allies, such as House Minority Leader Nancy Pelosi of California.

And then there was the African American president who has done vastly more for America’s LGBT citizens than all of his predecessors put together. It is especially appropriate that the greatest champion we have ever had in the White House is a black American, because the success of the gay liberation movement flowed from our emulation of the fierce bravery of the nonviolent civil rights movement.

Obama spoke briefly and beautifully about the folks who “never imagined we’d come this far — maybe even some in this room,” and about the upcoming generation — “Malia’s, Sasha’s generation [who] instinctively know people are people and families are families. And discrimination, it’s so last century.”

So when my husband and I left the White House, we felt a glow of pride and wonderment. Outside, we paused so I could snap a shot of my Joe holding up the president’s proclamation of “Lesbian, Gay, Bisexual and Transgender Pride Month” with the People’s House behind him.

And then we woke up Sunday morning to the horrific news. My first reactions were those of a citizen furious at a Republican-dominated Congress that has refused to enact even the most limited gun control proposals. I worried that if this was described as another act of terrorism, it could fuel the xenophobic campaign of Donald Trump.

And when the shooter was identified as a Muslim, my thoughts passed to my newest Muslim friend, a recent graduate of the Columbia Journalism School, who is proud and out in New York City but doesn’t think he will ever be able to tell anyone in his own East African family about the way he loves.

After that, I spoke with Maloney, who had arranged our White House visit, about the necessary conversation to come: about anti-LGBT hatred, about gun violence and about terrorism.

But Maloney made what I think is an essential point, that the models for the gay community should be “the brave parishioners in Charleston, who even in the immediate aftermath of that horrific shooting responded with love and with dignity. They did not allow themselves to be defined by the hatred of their attacker, and neither should we.”

Frank Kameny died in 2011, yet there is little doubt he would have endorsed those sentiments. After seeing Stokely Carmichael declare on television in 1968 that “black is beautiful,” Kameny invented the first slogan of the gay liberation movement: “Gay is good.”

Gay is good,­­ and gay is strongest when we use the worst adversity to strengthen our commitment to liberty and life.