This November, in Denver, Leslie Herod became the first gay African-American to be elected to Colorado’s House of Representatives. One morning the following week, she awoke to find that she’d been tagged in a Facebook post: a Nissan belonging to one of her future constituents, a transgender woman named Amber Timmons, had been covered overnight with black spray paint. On the trunk door, above a bumper sticker reading “INSIST ON BLISS,” was a swastika; “TRUMP” was written on the hood. One set of doors bore the message “FAG DIE HE SHE”; the other read “TRANNY DIE.” “Neighbors sprung into action right away, making sure the hate was removed from the vehicle,” Herod, who based her get-out-the-vote efforts at Blush & Blu, a lesbian bar a few blocks from Timmons’s home, told me recently. “We have many victories to celebrate, and a lot more work to do.”

So goes this year’s entry in the annals of American gay life—by turns harrowing and heartening, and often both in close succession. In March, the North Carolina house passed H.B. 2, the infamous bill mandating that people with XX chromosomes and people with XY ones do their business in separate public bathrooms. Three months later, forty-nine people, most of them young Latinos, were killed by a gunman at Pulse, a gay night club in downtown Orlando, Florida. A record number of trans murders were recorded this year. And yet, before 2016 was out, trans Americans had been incorporated into the military; the North Carolina bathroom bill’s great champion, Governor Pat McCrory, had been unseated; and Carlos Guillermo Smith, a gay-rights activist of Peruvian descent, had been elected to the Florida House, representing a part of eastern Orlando where many Pulse victims lived. All six openly gay members of Congress were returned to Washington, and Oregon’s Kate Brown became the first L.G.B.T. person to be elected governor of any state. Over all, of the hundred and thirty-five candidates supported by the Victory Fund, an advocacy group that works to get L.G.B.T. politicians elected, eighty-seven won their races.

For L.G.B.T. Americans, as for so many others, the big question raised this year is Donald Trump. He’s waffled on the bathroom issue (though he did invite Caitlyn Jenner to use the lady’s room in Trump Tower), and he’s been vague on same-sex marriage, calling it “settled” law but vowing to appoint the kinds of judges who’d be sure to challenge it. His emerging Administration, meanwhile, is a “who’s who of homophobia,” as the Boston Globe put it. There’s Mike Pence, of course, whose written agenda, for his congressional race in 2000, included the hope that “homosexuals” would never be granted the protections of a minority group, and who last year, as Indiana’s governor, signed legislation allowing businesses to refuse gay customers on moral grounds. Tom Price, whom Trump selected to head the Department of Health and Human Services, has suggested that being gay is a choice; the family foundations of Betsy DeVos, the nominee for Education Secretary, have given money to organizations that support so-called conversion therapy. The most decorated L.G.B.T. opponent, though, might be K. T. McFarland, the nominee for deputy national-security adviser. In 2006, when she ran for a Senate seat in New York, New York magazine unearthed a letter, from 1992, in which she outed her brother, who was dying of AIDS, to their parents. “Have you ever wondered why I have never had anything to do with Mike and have never let my daughters see him although we live only fifteen minutes away from each other?” she wrote. “He has been a lifelong homosexual.”

What to make of a moment when L.G.B.T. Americans are both so empowered and so threatened? Most experts agree that it would be too logistically complicated for the Supreme Court to overturn Obergefell v. Hodges, which established a constitutional right to same-sex marriage, in 2015, but, without a federal commitment to protecting L.G.B.T. rights, we’re likely to see a proliferation of state-level bathroom bills and anti-anti-discrimination laws. Aisha Moodie-Mills, who heads the Victory Fund, took the long view: “We survived the eighties, when our friends were perishing around us, and our federal government turned its back on us. We survived the nineties, when we were relegated to second-class citizenship—Don’t Ask, Don’t Tell; the Defense of Marriage Act. We survived the early two-thousands, when constitutional amendments were passed in eleven states to ban people from getting married. We are standing now at the most advanced place in our history.”

According to a Pew survey conducted this year, eighty-seven per cent of Americans say they know a gay or bisexual person. Fifty-seven per cent support same-sex marriage, compared to thirty-five per cent who oppose it. A majority of Americans believe that transgender people should be able to use the public restroom that matches their gender identity. John Corvino, a professor of philosophy at Wayne State University who has written widely on gay rights, told me that the one change that is certain as we head into 2017 is a departure of "moral leadership" on a national level—the kinds of public gestures like the one President Obama made last month, when he awarded a teary Ellen DeGeneres the Presidential Medal of Freedom for her work in helping to “push our country in the direction of justice.” Presenting her with the medal, the President added, “It’s like Ellen says: we all want a tortilla chip that can support the weight of guacamole.”

The honoring of DeGeneres suggests a final way to measure cultural shifts: culture itself. In this respect, L.G.B.T. Americans may remember 2016 for its many moments of deliverance. In his acclaimed film “Moonlight,” Barry Jenkins told the wrenchingly uncertain story of a gay black boy growing up in the Miami projects. “Her Story,” a viral YouTube series that was nominated for an Emmy, features two trans women who, unlike Maura Pfefferman in the pathfinding “Transparent,” are played by trans actors. Amanda Nunes, a Brazilian martial artist, became the first gay fighter to win a U.F.C. championship; the Christian rocker Trey Pearson came out after having “tried not to be gay for more than twenty years,” as he wrote in a letter to fans. These stories make a difference, especially in parts of America where coming out can still invite violence, especially against trans people. Jennifer Finney Boylan, the trans writer and activist, told me, “It’s impossible to hate anyone whose story you know.”

When I asked the advice columnist Dan Savage, who has been apoplectic about Trump’s victory, where we stand, he was surprisingly sanguine. He waved away the threat of the men he called Trump's "gay kapos," Peter Thiel and Milo Yiannopoulos ("Every community has its knuckle-dragging bigots"), and told me that even as political battle continues in the trenches—“moving slowly through the three branches of government, with lots of casualties, because gay people are always losing”—the war has already been halfway won. He mentioned one indication of how far the cultural ground has moved: this week’s obituaries for the pop star George Michael, hailing him for the very audaciousness that had earned him revulsion in 1998, when he was outed after an arrest for public lewdness and said, “I don’t feel any shame whatsoever.” In the guerilla war of cultural influence, Savage told me, “We’ve gone so far behind enemy lines that the lines have collapsed.”