The Supreme Court divided along ideological lines Tuesday in sharply-debated cases over whether a federal civil rights law protects LGBTQ employees from job discrimination.

Hundreds of people on both sides of the issue rallied outside the court, many carrying rainbow flags.

SUPREME COURT KICKS OFF ELECTION-YEAR AGENDA WITH HOT-BUTTON IMMIGRATION, GUNS AND ABORTION CASES

The sidewalk and outdoor plaza were cleared after two suspicious packages were discovered in front of the courthouse, just before the justices heard the cases. Media, protesters, and those waiting in line for arguments were cleared from the immediate area.

Two gay men brought separate lawsuits alleging they were fired from their jobs because of their sexual orientation.

A transgender woman made a similar claim, after announcing to her co-workers at a funeral home she was transitioning from male to female.

Some conservative justices said Congress never considered LGBTQ employees when it passed the Civil Rights Act of 1964, aimed at ending discrimination "because of... sex."

Others on the bench said courts have and should continue to hear such disputes, in the absence of any recent legislation.

"The text of the statute appears to be pretty firmly" in favor of the two gay employees bringing suit, said Justice Elena Kagan. "Did you discriminate against somebody... because of sex? Yes, you did. Because you fired the person because this was a man who loved other men."

But Justice Samuel Alito worried about judicial intervention at this stage.

"Congress has been asked repeatedly in the years since 1964 to address this question," he said. "Congress has declined or failed to act on these requests. And if the Court takes this up and interprets this 1964 statute to prohibit discrimination based on sexual orientation, we will be acting exactly like a legislature."

Gerald Bostock was terminated in 2013 from his government job, he alleges because of his homosexuality. The Georgia county said it was because of work performance.

Daniel Zarda was fired from his job as a skydiving instructor in 2010, and made a similar claim. His employer said it acted after some clients complained. Zarda died in 2014 and his estate sued.

The transgender case comes from Aimee Stephens, a Detroit-area funeral home worker who was released by her employer after she began transitioning. The high court could also decide if another federal law, the Religious Freedom Restoration Act (RFRA), provides any exemption from Title VII if the employer claims the discrimination is based on sincere religious beliefs.

Solicitor General Noel Francisco, supporting the funeral home on behalf of the Trump administration, said "sex and gender identity, like sex and sexual orientation, are different traits. They have different definitions." He said that was true in 1964 and is true today.

But Justice Stephen Breyer noted the history of discrimination against the LGBTQ community and other laws designed to address that disparity over the succeeding years.

"That's a change that both explains why they didn't put it in initially and explains why we should, other things being equal, interpret it to include gay people and transgender people now" in job discrimination claims.

Justice Sonia Sotomayor stepped in.

"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, not because they can't do whatever is required of a position, but merely because they're a suspect class to some people," she said. "At what point do we say we [the courts] have to step in?"

Most of the justices used wide-ranging hypotheticals to explore when discrimination might apply.

Chief Justice John Roberts cited workplace restrooms.

"If we analyze the bathroom case purely on the basis of biological sex, maybe you have one answer," he said. "But if you analyze it in terms of transgender status, you have a different answer, because men and women who identify with their biological sex aren't disadvantaged whether they are using the men's room, they each can use their own restroom. But the issue is quite different if you are dealing with a transgender individual who wants to use the restroom of their gender identity, contrary to their biological sex."

Roberts called that potentially a "huge problem."

Justice Neil Gorsuch noted such disputes are not easy for fellow judges to decide.

"It's close, okay?" Gorsuch hypothesized. "At the end of the day, should he or she take into consideration the massive social upheaval that would be entailed in such a decision, and the possibility that Congress didn't think about it, and that is more appropriately a legislative rather than a judicial function? That's it. It's a question of judicial modesty."

But earlier, Gorsuch suggested that when it comes to comparative discrimination analysis, "at least one contributing cause appears to be sex?"

His tough questions on both sides could signal a divide among the court's conservative majority.

"Some of the conservatives like to think of themselves as strict textualists," taking a literal reading of the statute, that might favor the plaintiffs, said Paul Smith, a Georgetown law school professor who has argued cases before the high court for LGBT clients. "You can certainly imagine one of them peeling off and saying: look, I need to follow my methodology I need to be fair to what I've always told people is how I read a law and this is such a situation. So it's conceivable you could have a division among the conservatives."

The high court's 2015 landmark ruling legalizing same-sex marriage nationwide opened the door to subsequent legal challenges over the rights enjoyed by those in the LGBTQ community. The transgender case could also impact pending appeals in a range of lawsuits against businesses that claim a religious liberty right to deny their services, a view the Trump administration has often embraced. 21 states currently have anti-discrimination laws that specifically include gay and lesbian people.

The Equal Employment Opportunity Commission in the Obama era reinterpreted civil rights law to include LGBTQ discrimination, but the Trump administration has tried to reverse course.

The issue now for the justices is whether their three-decade old ruling recognizing discrimination based of sexual stereotypes can be applied in the gender identity and sexual orientation context.

Outside the court, plaintiffs from both sides urged Congress to intervene.

"The ACLU is trying to use my grandfather's business as a pawn to achieve a larger political goal," said Thomas Rost, co-owner of the Michigan funeral home. "It has been unable to achieve in Congress, where this issue belongs."

But plaintiff Gerald Bostock said the issue was about job security for the estimated eight million LGBT American workers.

"We're talking about millions and millions of people who go to work every day, fearful for being fired for who they are, who they identify, and who they love. And that's wrong."

One amusing line of questioning in the courtroom concerned what constituted discrimination.

"When I got up, the Chief Justice said to me, 'Ms.' Karlan," said Pamela Karlan, attorney for the two gay employees. "I am willing to bet any amount of money I have that when [opposing attorney] Mr. Harris gets up, he [Roberts] is going to say 'Mr.' Harris. He treated us differently because of sex. That is not discriminatory because neither of us has been subjected to a disadvantage."

Maybe, but Roberts had mischief in mind.

When Jeffrey Harris stood up to address the court, the chief justice merely said "Counsel," bringing courtroom laughter.

"Mr. Chief Justice, and may it please the Court," replied Harris, smiling and emphasizing "mister."

"Touché," said Roberts.

The sexual orientation cases are: Bostock v. Clayton County, GA (17-1618); Altitude Express, Inc. v. Zarda (17-1623).

The transgender appeal is R.G. & G.R. Harris Funeral Homes v. EEOC & Aimee Stephens (18-107).

Rulings are expected by next summer.