A few days before a majority-conservative U.S. Supreme Court voted to enact the most sweeping legal protections for LGBTQ Americans in decades, a Republican congressman in Virginia lost his election after he officiated a same-sex wedding last year.

The wedding wasn’t the only reason conservatives targeted Rep. Denver Riggleman in a party convention (which local party officials set up in place of a primary), but it was the driving one. Which raises the question: How out of step with the nation is the Republican Party on same-sex rights?

It’s an especially pertinent question on Monday, now that the Supreme Court, with the support of one of President Trump’s nominees, just voted 6-3 that existing federal law protects gay and transgender workers from discrimination based on sex.

That’s a sea change in the legal landscape of protections for LGBTQ Americans. Before this ruling, in about half of the states, you could be legally fired for being gay or transgender. Now, you can’t under the 1964 Civil Rights Act, which the court ruled extends to LGBTQ Americans because it prevents discrimination “on the basis of sex.”

But like the Republican voters in Virginia who ousted Riggleman in favor of social conservative Bob Good, there is an active wing of the Republican Party seeking to push back on the march toward expanding legal protections for gay and transgender Americans. And they have powerful allies.

The Trump administration opposed interpreting the Civil Rights Act to encompass LGBTQ workers. The leader of the conservative Judicial Crisis Network called the six justices who supported this ruling, one of whom was Trump appointee Neil M. Gorsuch, “activists,” implying the court got ahead of where the public is on the issue. (Trump appointee Brett M. Kavanaugh wrote a dissent to the ruling.)

Nationally, the Republican Party is running in 2020 on a platform that opposes same-sex marriage and expanding workplace protections to LGBTQ Americans. That was part of the party’s 2016 platform that it rolled over to this campaign.

But the broader public is generally quite supportive of gay rights — including Republicans. A CBS News poll in June found 82 percent of Americans say that lesbian, gay and bisexual people should have civil rights protections, including 71 percent of Republicans.

The public opinion shift in favor of same-sex marriage, and more broadly gay and transgender rights, has been remarkably fast. Support in favor of legalizing same-sex marriage grew by 20 percentage points over six years, from 40 percent in favor in 2009 at the start of Barack Obama’s presidential term to 60 percent in 2015, as the Supreme Court legalized it nationwide, according to Gallup polling.

“This is an unprecedented shift in public opinion,” Republican pollster Glen Bolger told The Fix at the time. “In 20 years, it won’t even be an issue.”

Where the nation and Republicans differ today, according to that CBS News poll, is on transgender rights. A 55 percent majority of Americans overall said transgender people face a lot of discrimination, but that dipped to 38 percent among Republicans.

Still, a majority of Republicans said both groups faced at least “some” discrimination in society today.

The Republican voters in Virginia who ousted Riggleman were highly concentrated among the most hardcore party activists. The local party decided to set up a convention rather than a primary, meaning party members who wanted to participate had to drive as much as three hours across the vast 5th District to cast a drive-through vote in the convention.

Riggleman is contesting the results, alleging unspecified allegations of “voting irregularities” and “ballot stuffing.” If he remains the loser, Democrats hope to pick up this conservative-leaning district for the first time in a decade, calculating Good, who opposes abortion in all cases in addition to opposing same-sex marriage, is too conservative for a broader electorate.

It seems possible Bolger’s prediction of gay rights quickly becoming a nonissue could happen with the majority of the nation, including the Republican Party. But there is still a vocal contingency of social conservatives within the party who are active enough to oust a sitting congressman over his support for gay rights, the same week the Supreme Court took a historic step to expand them.

Emily Guskin contributed to this report.