WASHINGTON – The Supreme Court appeared deeply divided Tuesday on a major civil rights question: whether gay and transgender people are covered by a federal law barring employment discrimination on the basis of sex.

The court's rulings in three cases, which are not expected until next year, seemed to hinge on President Donald Trump's two nominees. Associate Justice Neil Gorsuch called the dispute over transgender rights "close" but more likely an issue for Congress to address. Associate Justice Brett Kavanaugh directed his only question to a lawyer for two employers that fired gay workers, leaving his position in doubt.

The court's four liberal justices forcefully denounced the firings of two gay men and a transgender woman from Georgia, New York and Michigan and made clear they believe all three should be protected by the statutory ban on sex discrimination.

"We can't deny that homosexuals are being fired merely for being who they are and not because of religious reasons, not because they are performing their jobs poorly," Associate Justice Sonia Sotomayor said, calling it "invidious behavior."

More:SCOTUS ruling could alter lives of LGBTQ Americans

The three cases are among the most significant on the high court's 2019 docket, and the justices' rulings are likely to come in the heat of the 2020 presidential campaign.

The challenges pick up where the same-sex marriage battle left off in 2015, when the court ruled 5-4 that states cannot bar gay men or lesbians from getting married.

What's different is the court itself: The author of four major opinions expanding gay rights, Anthony Kennedy, retired last year and was succeeded by the more conservative Kavanaugh. If his vote was counted on by those taking the employers' side, he gave no hints. He was mostly silent during Tuesday's two hours of oral arguments.

Gorsuch said sex was at least "in play," an acknowledgment that the gay and transgender workers claiming sex discrimination have a reasonable argument. What he did not say: that the courts should fix it.

Instead, Gorsuch said the "massive social upheaval that would be entailed in such a decision" in the fired workers' favor points more toward Congress. "It's a question of judicial modesty," he said.

The three plaintiffs are Gerald Bostock, 55, a former child welfare services coordinator from Georgia; Donald Zarda, a former New York skydiving instructor who died at 44 in 2014 but is represented by his sister and former partner; and Aimee Stephens, 58, a former funeral home worker from Michigan who is transgender.

Bostock, Zarda:Gay rights battle against employment discrimination extends beyond the grave, and to the Supreme Court

Stephens:Ex-funeral home worker’s case going to Supreme Court, raising question whether 1964 law covers gender identity

Throughout the debate inside a packed courtroom, the court's conservative and liberal justices tangled over the text of the 1964 statute, the proper male-female and gay-straight comparisons to make and the role of the courts in righting societal wrongs.

The conversation veered from comparisons made by liberal justices between same-sex relationships and interfaith marriages, to concerns voiced by conservative justices that a win for LGBT rights would endanger men's and women's restrooms, dress codes and fitness tests.

Rather than claiming a constitutional right to equal treatment, the challengers must convince at least five justices that the word "sex" in the Civil Rights Act of 1964 incorporates sexual orientation and gender identity.

"All you need to do is show that sex played a role here," said Pamela Karlan, the lawyer representing Bostock and Zarda.

That clearly was a stretch for some conservative justices.

"You're trying to change the meaning of what Congress understood sex to mean in 1964," Associate Justice Samuel Alito said. While Associate Justice Clarence Thomas stayed characteristically silent, Alito seemed most aligned with the employers and the Trump administration.

Solicitor General Noel Francisco argued both cases alongside lawyers for the Georgia county, New York skydiving company and Michigan funeral home. Sex, he said, "means whether you're male or female, not whether you're gay or straight."

Outside court, hundreds of LGBTQ demonstrators rallied, undeterred by a security threat that forced police to cordon off the street early Tuesday morning when two suspicious packages were noticed.

Katherine Fuchs, 38, said she came to the demonstration because she was “outraged that in 2019, someone could be fired for their sexual orientation or gender identity.”

How the court rules may come down to the comparison justices make. For instance, do they compare Bostock and Zarda to women who date men, as the plaintiffs want, or to women who date women, as their employers and the Trump administration want?

The impact of a victory for Bostock, Zarda and Stephens would be greatest in 28 states that have little or no workplace protection for the LGBT community. Even in states such as New York, which does, incorporating sexual orientation in the federal law barring discrimination based on race, color, religion, sex or national origin would add an important layer of protection.

About 4.5% of the U.S. population, or roughly 11 million people, identify as LGBTQ, of which 88% are employed.

More:Half of LGBTQ adults live in states where no laws ban job discrimination

Federal appeals courts have been split on the question since 2017, when the U.S. Court of Appeals for the 7th Circuit became the first to rule that gay men and lesbians should be covered by the decades-old federal civil rights law. The 2nd Circuit ruled for Zarda last year, but the 11th Circuit, based in Atlanta, ruled against Bostock. The 6th Circuit, based in Cincinnati, ruled for Stephens last year.

Congress has debated the issue for decades but "repeatedly declined to pass bills adding sexual orientation to the list of protected traits" under the law, the Justice Department noted. The Democratic-controlled House passed the Equity Act this year, but the Republican-controlled Senate has not considered it.

If the court rules that LGBTQ workers are protected under the civil rights law, it could help them win other rights in areas such as housing, education, health care and credit.

More than 200 companies representing more than 7 million workers have lined up with the employees, contending that "the U.S. economy benefits from a diverse workforce."

Many religious organizations root for the employers. The U.S. Conference of Catholic Bishops said opening employment protection to gay men and lesbians could adversely affect faith-based schools, health care providers and homeless shelters that seek to abide by their own "religious and moral convictions."

Contributing: Susan Miller