The Supreme Court on Monday handed down a momentous decision on gay rights, ruling that employers can’t discriminate against their employees on the basis of their sexual orientation.

Those celebrating the decision can thank a segregationist.

The Supreme Court decided the case on a 6-to-3 majority, with conservative Justices John G. Roberts Jr. and Neil M. Gorsuch, the latter who wrote the opinion, joining the court’s four liberal justices. Essentially, the decision says that Title VII of the Civil Rights Act of 1964, which outlaws discrimination based on “race, color, religion, sex, or national origin,” necessarily includes a prohibition on discrimination based on sexual orientation.

“An employer who fires an individual for being homosexual or transgender fires that person for traits or actions it would not have questioned in members of a different sex,” Gorsuch wrote. “Sex plays a necessary and undisguisable role in the decision, exactly what Title VII forbids.”

What’s notable here is that the Civil Rights Act didn’t initially include the prohibition on sex discrimination. It wasn’t added to the bill until the final day of debate by a segregationist congressman, Howard Smith (D-Va.).

On the eighth day of debate in the House, Smith rose to argue in favor of including sex in the bill. According to a 2017 book by Gillian Thomas, Smith read a letter from a female constituent asking him to “protect our spinster friends” who were suffering from a shortage of eligible bachelors. Smith said: “I read that letter just to illustrate that women have some real grievances and some real rights to be protected. I am serious about this thing.”

At the time and since, the effort drew laughs from his colleagues, many of whom viewed it as an attempted “poison pill” — i.e., an amendment that lawmakers would adopt because it was difficult to vote against, but that would nonetheless help kill the entire package, which segregationists such as Smith opposed. President Lyndon B. Johnson and other proponents of the bill opposed the amendment on those grounds.

But the few women who served in the House at that time rose to support it, arguing that passing the law without including women would relegate women to “a second-class sex,” as then-Rep. Martha Griffiths (D-Mich.) said. She went so far as to say the law would provide black women with more rights than white women.

“A vote against this amendment today by a white man is a vote against his wife, or his widow, or his daughter, or his sister,” she said.

According to Todd S. Purdum’s 2014 book, then-Rep. Katharine St. George (R-N.Y.) said, “I can think of nothing more logical than this amendment at this point.” She added: “We outlast you. We outlive you, we nag you to death. … We are entitled to this little crumb of equality. The addition of the little, terrifying word s-e-x will not hurt this legislation in any way.”

The amendment passed, and so did the entire bill.

To this day, some regard Smith’s amendment as a fateful miscalculation. There is little doubt that he wanted the bill killed, given he ultimately voted against it. At one point before its passage, Smith remarked that the bill was “as full of booby traps as a dog is of fleas.”

But as Thomas also notes in her book, Smith’s motives aren’t entirely clear. Although he was a segregationist, he had also advocated for an Equal Rights Amendment for women. Supporters of the ERA, most of whom were white, had indeed decried codifying protections for African Americans that weren’t also provided to white women.

Either way, though, the inclusion of that word — “sex” — led to significant steps forward for women’s rights over the past five-plus decades. Now it has also led to a major step forward for LGBTQ Americans, which is something Smith could hardly have anticipated from his “little amendment.”