The case, brought by a class of immigrants who seek hearings to prove that they are neither flight risk nor a danger to society, comes at a time when immigration groups lament the fact that the Obama administration deported record numbers of immigrants and the Trump administration has vowed to crack down further on enforcement.

“Under the Obama administration, immigration detention has skyrocketed to record levels,” said Cecilia Wang, the director of the ACLU Immigrants’ Rights Project and a lawyer for the class of immigrants. Wang said the case “is fundamentally about whether the executive branch has unchecked power to detain someone without a hearing –something that is contrary to the most basic principles behind the founding of the United Sates.”

Lower courts are divided on how they interpret the immigration detention statutes at issue in the case.

The liberal justices on the bench seemed sympathetic to parts of an opinion by the 9th Circuit Court of Appeals that ruled in favor of the class of immigrants, requiring an individualized procedure after six months of detention. The court stressed that while it was mandating that immigration judges hold hearings for certain individuals, it was not ordering them to release any single individual.

In court, Justice Elena Kagan expressed concern that deportation proceedings are sometimes delayed because of government backlog.

“I think we would all look at our precedent and we would say, you can’t just lock people up without any finding of dangerousness, without any finding of flight risk, for an indefinite period of time, and not run into due process,” she said.

“If these are people who have been here for decades,” Justice Sonia Sotomayor asked the government lawyer, “don’t’ you think due process would require some periodic review to ensure that these people are properly held?”

Acting Solicitor General Ian H. Gershengorn rejected the lower court opinion, calling it a “one size fits all rule” that would undo the “legislative balance.” Congress sought between providing procedural protections for aliens whom the government wishes to remove, “but at the same time addressing concerns about recidivism and flight risk,” he said.

More than once, Gershengorn stressed that immigrants can seek relief by filing suit in federal court, but lawyers for the immigrants called that a non-starter because the class consists of people without representation who are not familiar enough with the legal system to file such a claim.

Justice Anthony Kennedy — often the critical swing vote — did not seem to tip his hand. If the court finds itself evenly split it could choose to hold the case until there is a ninth justice. In a separate case back in 2003 Kennedy approved the detention of aliens but plaintiffs distinguish that case arguing that it was premised on the notion that the detentions would be brief.

At one point Chief Justice John Roberts questioned whether the case should be sent down to the lower court for further review.

“Our job is to read the statute and if it presents — if it’s unconstitutional, that’s our job,” he said. “But we can’t just write a different statute because we think it would be more administrable.”

Kagan was quick to push back. “We’re not making up a statute” she said “we’re devising a constitutional limit.”

The case is complicated by the diversity of the class presented as well as the fact that three immigration statutes are in play.

The class of immigrants in the case are all incarcerated and they include lawful permanent residents with minor criminal history and asylum seekers who have passed an initial screening but who are waiting for the chance to raise their claims. Lawyers for the class says that it does not include any individuals that the government deems to be national security risks. They are covered by separate statutes not at issue.

The lead plaintiff, Alejandro Rodriguez, is a lawful permanent resident who was brought to the United States as an infant. He was employed as a dental assistant when he was put in removal proceedings based on possession of a controlled substance and “joyriding.” He was detained for over three years while he challenged his removal. He eventually managed to appeals his case in a process that took over seven years.

“Mr. Rodriguez’s case is not unique” his lawyers argued.

The government argued that the lower court opinion represented a “dramatic and wholesale revision” to the long standing system and replacing it with “a radical new one in which aliens arriving at our borders or convicted of crimes have a presumptive entitlement to be released in the United States, “if custody during removal proceedings last six months.”