WASHINGTON — The Supreme Court justices sounded closely split Tuesday and a bit uncertain over whether to make it illegal under federal law for companies and public agencies to fire employees solely because they are gay, lesbian or transgender, with Justice Neil M. Gorsuch likely the deciding vote.

"This case is really close," said Gorsuch, President Donald Trump's first appointment to the high court, during oral arguments over whether the 1964 federal ban on discrimination on the basis of "sex" applies to LGBTQ people. He told an ACLU lawyer arguing in favor of a transgender woman who was fired: "I'm with you on the text."

But Gorsuch went on to say that it is a matter for Congress, not the court. "It's a question of judicial modesty," he said.

The exchange summed up much of the two hours of arguments. The justices, or at least several of them, said they agreed that firing gays or transgender employees sounded like sex discrimination, which is prohibited by federal law. But others, including most of the conservatives, said that Congress in 1964 did not mean to outlaw discrimination based on sexual orientation or gender identity.

The historic law had been understood for decades as protecting women from being denied jobs or promotions that went to men instead.

But in recent years, the U.S. Equal Employment Opportunity Commission, which enforces the law, decided it also protects gays, lesbians and transgender employees. It did by concluding that discrimination based on sexual orientation or gender identity is illegal discrimination because of sex. U.S. appeals courts in New York and Chicago similarly found the law applies to gay and lesbian workers, while the Cincinnati appeals court said it applies to transgender people.

The Justice Department argued that the law should not cover gay, lesbian and transgender workers. Noel Francisco, the Trump administration's solicitor general, urged the court to reject the discrimination claims. "Sex and sexual orientation are two different traits," he said. "This is an issue better left to Congress."

But Justice Ruth Bader Ginsburg said the court had repeatedly read the 1964 law to go beyond the problems of the 1960s. She cited the issue of sexual harassment, which did not emerge until the late 1970s. But in the end, she said, the court had no trouble concluding that sexual harassment constituted discrimination based on sex.

Justice Samuel A. Alito Jr., a staunch conservative, took the opposite view. "We will be acting exactly like a legislature," he said, if the court rules now that the 1964 forbids discrimination based on sexual orientation.

Chief Justice John G. Roberts Jr. asked whether the court should be in the business of "updating old statutes" and said the word "sex" was understood at the time to mean men and women.

Stanford law professor Pamela Karlan, who argued on behalf of two gay men who were fired, said even with that understanding, the law should apply in this case.

"When a employer fires a male employee for dating men, but does not fire female employees who date men, he violates Title VII," she said, referring to a provision of the 1964 law. "The employer has ... discriminated against the man because he treats that man worse than women who want to do the same thing. And that discrimination is because of sex."

Gorsuch said several times that he could accept the argument that firing a gay or transgender employee involved sex discrimination. When a lawyer defended an employer who allegedly fired a gay employee, Gorsuch said he did not see how sex played no role.

"Let's do truth serum, OK? Wouldn't the employer maybe say it's because this person was a man who liked other men? And isn't that first part sex?" Gorsuch asked. At the same time, he also voiced concern about what he called the "massive social upheaval" that might be caused by extending the law to LGBTQ workers.

It is the first significant gay rights case before the high court since Justice Brett M. Kavanaugh replaced the retired Justice Anthony M. Kennedy. Though a moderate conservative, Kennedy wrote all of the court's opinions upholding the rights of gays and lesbians, including the 2015 decision upholding the right to marry for same-sex couples. Kavanaugh said little during the arguments, so his views remain unclear.

At present, federal anti-discrimination laws do not protect gays, lesbians or transgender workers. The House under Democratic control passed the Equality Act in May to amend the Civil Rights Act and to prohibit discrimination on the basis of "sexual orientation, gender identity, pregnancy (or) childbirth." But the measure is stalled in the Republican-controlled Senate.

California and 21 other states forbid discrimination based on sexual orientation, and several other states have such protections for public employees. But there are few such protections in the South and much of the Midwest and Great Plains.

The justices heard arguments in three cases: two involving gay men and one involving a transgender woman.

Gerald Bostock said he was fired from his position as a child welfare services coordinator in Clayton County, Ga., not long after he joined a gay softball league. He appealed in Bostock v. Clayton County after his discrimination suit was tossed out.

In 2010, Donald Zarda was fired from his job as a sky-diving instructor in New York after jokingly assuring a woman customer she had nothing to fear from being strapped to him in the air because he was gay. He later died in an accident, but his sister has pursued his suit in Altitude Express v. Zarda.

Aimee Stephens said she was fired from her job at a family-run funeral home in Detroit after she returned from a vacation as a woman. The EEOC sued on her behalf, but the court will hear the employer's appeal in R.G. & G.R. Harris Funeral Homes v. EEOC.

Los Angeles Times