In this Oct. 8, 2019, file photo, supporters of LGBTQ rights hold placards in front of the U.S. Supreme Court in Washington. The Supreme Court has ruled that a landmark civil rights law protects gay, lesbian and transgender people from discrimination in employment. It's a resounding victory for LGBT rights from a conservative court. (AP Photo/Manuel Balce Ceneta, File) Supreme Court LGBT Rights
In this Oct. 8, 2019, file photo, supporters of LGBTQ rights hold placards in front of the U.S. Supreme Court in Washington. The Supreme Court has ruled that a landmark civil rights law protects gay, lesbian and transgender people from discrimination in employment. It's a resounding victory for LGBT rights from a conservative court. (AP Photo/Manuel Balce Ceneta, File)

A racist congressman from Virginia tried to stop the Civil Rights Act, but 56 years later his amendment got more legal protections for LGBTQ Americans.

In a landmark decision Monday, the Supreme Court ruled that federal law protects LGBTQ people from workplace discrimination. The ruling has been a long time coming in the fight for equal rights for gay, bisexual and transgender Americans, and it unexpectedly has ties to a segregationist congressman from Virginia. 

The Supreme Court case dealt with the Civil Rights Act of 1964, which prohibits discrimination based on a person’s race, religion, national origin and sex. The question before the court was whether the “basis of sex” applies to gay and transgender workers. The justices ruled, 6-3, that it does, and that it would be illegal to fire someone based on their sexual orientation or identity.

RELATED: What Virginia’s New LGBTQ Protections Really Do

Paradoxically, former Rep. Howard Smith of Virginia, a staunch segregationist who led the powerful House Rules Committee and tried to derail the Civil Rights Act at every possible point, helped make today’s decision happen.

Smith, who served in Congress from 1931 to 1967 and represented northern Virginia’s 8th district, offered several “poison pill” amendments to the Civil Rights Act in an effort to stop it from becoming law. One of those amendments was adding the word “sex” into the bill. But the amendment ultimately passed, and it didn’t stop the overall bill from becoming law. And including “sex” led to Monday’s decision from the Supreme Court.

“A reminder that the word “sex” was inserted into Title VII by a segregationist Democrat to try and kill the Civil Rights Act. One of the great self-owns of American legislative history,” Adam Serwer of the Atlantic wrote on Twitter.

When Smith introduced the amendment on the House floor in February 1964, he claimed he was “very serious” about it. He then proceeded to sarcastically read a letter from a woman who complained that there were more women than men in America, leading to an “imbalance of spinsters.”

“I am sure you will agree that this is a grave injustice to womankind,” Smith jokingly said on the House floor.

Despite Smith’s intentions, some female members of Congress supported both the amendment and the Civil Rights Act, ultimately helping both to pass. Former Rep. Edith Green (D-Ore.) called Smith and his colleagues out for their antics.

“If I correctly understand the mood of the House, those gentlemen…who are most strong in their support of women’s rights this afternoon, probably gave us the most opposition when we considered the bill which would grant equal pay for equal work just a very few months ago,” Green said. “I say I welcome the conversion and hope it is of long duration.”

A month before this exchange, Smith made his racist stance clear in a television news interview.

“I’ve been in Congress for 33 years and I never saw any organized minority with political power that was ever satisfied with their [place],” he said. “They have a lot of people with their own salary they have a big payroll they get at one objective [after another] if they don’t a lot of them would be out of a job.”

Fifty-six years later, Smith’s amendment to include “sex” in the Civil Rights Act accomplished quite the opposite of what he hoped.