Washington CNN  — 

Federal civil rights law protects gay, lesbian and transgender workers, the Supreme Court ruled Monday.

The landmark ruling will extend protections to millions of workers nationwide and is a defeat for the Trump administration, which argued that Title VII of the Civil Rights Act that bars discrimination based on sex did not extend to claims of gender identity and sexual orientation.

The 6-3 opinion was written by Justice Neil Gorsuch, President Donald Trump’s first Supreme Court nominee, and joined by Chief Justice John Roberts and the court’s four liberal justices.

“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. Sex plays a necessary and undisguisable role in the decision, exactly what Title VII forbids,” Gorsuch wrote.

“There is simply no escaping the role intent plays here: Just as sex is necessarily a but-for cause when an employer discriminates against homosexual or transgender employees, an employer who discriminates on these grounds inescapably intends to rely on sex in its decisionmaking,” the opinion read.

“Today’s decision is one of the court’s most significant rulings ever with respect to the civil rights of gay and transgender individuals,” said Steve Vladeck, CNN Supreme Court analyst and professor at the University of Texas School of Law.

“On its terms, the decision is only about discrimination in the workplace,” Vladeck added. “But it inevitably opens the door to a host of other challenges to discrimination on the basis of sexual orientation or transgender status on the ground that it, too, is impermissibly based upon sex. In that respect, only the court’s 2015 ruling recognizing a constitutional right to same-sex marriage may be equally as significant.”

Speaking at the White House, Trump called the decision “very powerful” and acknowledged it was surprising to some.

“They’ve ruled and we live with the decision,” Trump said. “We live with the decision of the Supreme Court.”

Presumptive Democratic presidential nominee Joe Biden called the ruling “a momentous step forward for our country.”

“The Supreme Court has confirmed the simple but profoundly American idea that every human being should be treated with respect and dignity. That everyone should be able to live openly, proudly, as their true selves without fear,” Biden said.

The LGBTQ community is made of up of approximately 1 million workers who identify as transgender and 7.1 million lesbian, gay and bisexual workers, according to UCLA’s Williams Institute.

Twenty-two states, plus the District of Columbia have statutes protecting workers based on sexual orientation, according to the Williams Institute. Twenty-one states plus DC have statutes protecting workers from discrimination based on gender identity.

Justice Samuel Alito, one of the court’s conservatives, wrote in his dissent that “even if discrimination based on sexual orientation or gender identity could be squeezed into some arcane understanding of sex discrimination, the context in which Title VII was enacted would tell us that this is not what the statute’s terms were understood to mean at that time.”

Meanwhile, Justice Brett Kavanaugh, another conservative on the bench, acknowledged the social and political progress achieved by members of the LGBTQ community, but nonetheless dissented.

“They have advanced powerful policy arguments and can take pride in today’s result. Under the Constitution’s separation of powers, however, I believe that it was Congress’s role, not this Court’s, to amend Title VII. I therefore must respectfully dissent from the Court’s judgment,” Kavanaugh wrote.

A number of LGBTQ groups celebrated the court’s ruling on Monday, including the Human Rights Campaign, whose president, Alphonso David, said in a tweet that the decision is a “landmark victory for #LGBTQ equality.”

Sarah Kate Ellis, the president of the LGBTQ advocacy group GLAAD, said in a statement that the decision “is a step towards affirming the dignity of transgender people, and all LGBTQ people.”

But the ruling was also sharply criticized by the conservative Judicial Crisis Network, whose president issued a blistering statement about Gorsuch, who replaced the late Justice Antonin Scalia.

“Justice Scalia would be disappointed that his successor has bungled textualism so badly today, for the sake of appealing to college campuses and editorial boards,” said Carrie Severino, a former clerk of Justice Clarence Thomas. “This was not judging, this was legislating – a brute force attack on our constitutional system.”

Gorsuch grounded his opinion in the plain text of the law. He acknowledged that when the law was passed, Congress may not have been thinking of gay, lesbian and transgender rights.

The conservative justice said Congress might not have “anticipated their work would lead to this particular result,” but, he said, the “express terms of the statute give us one answer.”

“Only the written word is the law, and all persons are entitled to its benefit,” he wrote in the ruling.

An historic ruling

The court’s ruling was on separate cases: one concerning whether the law encompasses claims of sexual orientation brought by Gerald Bostock, and the estate of Donald Zarda, and the other concerning a transgender woman, Aimee Stephens, whose challenge marked the first time the court heard arguments regarding the civil rights of a transgender individual.

Stephens, who died in May, mustered the courage back in 2013 to tell her co-workers about something that she had struggled with her entire life: her gender identity. Not long after, she was fired as the director of a funeral home.

Stephens’ former boss, Thomas Rost, testified in the lower court that she was fired because she was “no longer going to represent himself as a man.” (Rost refused to address Stephens with feminine pronouns).

A lower court ruled in her favor, holding it is “analytically impossible to fire an employee based on that employee’s status as a transgender person without being motivated, at least in part, by the employee’s sex.”

Aimee Stephens’ wife, Donna Stephens, also welcomed the court’s ruling on Monday, saying in a statement that Aimee was “a leader who fought against discrimination against transgender people.”

“I am grateful for this victory to honor the legacy of Aimee, and to ensure people are treated fairly regardless of their sexual orientation or gender identity,” Donna Stephens said.

Bostock, a gay man from Georgia who claimed that despite receiving good performance reviews as a child welfare services coordinator, argued he was fired because of his sexual orientation. Another plaintiff was the estate of Donald Zarda, who had been employed as a sky diving instructor. Zarda has since died but he too claimed to be fired because he was gay.

This story has been updated with comment from President Trump.