A U.S. appeals court ruled Thursday that a Sri Lankan immigrant can appeal his fast-track deportation order to the federal courts, after immigration officials attempted to expel him without a full hearing.

The American Civil Liberties Union, which filed the lawsuit, called the ruling “historic” and said it could affect thousands of immigrants apprehended at the border and subjected to “expedited removal,” a streamlined deportation process that President Trump wants to expand.

Justice Department spokesman Steven Stafford declined to comment and the Department of Homeland Security did not respond to questions Thursday.

The ruling, by three Democratic appointees in the U.S. Court of Appeals for the 9th Circuit, centers on the case of Vijayakumar Thuraissigiam, an immigrant who crossed the southern border illegally in 2017 and asked for asylum, saying Sri Lankan government agents had abducted, beaten and nearly drowned him for backing a minority political candidate.

Homeland Security detained him that year and placed him in expedited removal, created under a 1996 immigration law that lets border and immigration agents swiftly deport recently arrived foreigners, who do not have legal papers, without a hearing or the right to appeal to the judicial branch.

Those who fear for their lives are entitled to an asylum interview, but if they fail that, their only appeal is a cursory review by one of the Justice Department’s administrative immigration judges.

In the ruling, Judge A. Wallace Tashima said the system offered “meager procedural protections” and should not block foreigners from seeking judicial review of their cases.

“We think it obvious that the constitutional minimum . . . is not satisfied by such a scheme,” he wrote.

The ruling overturned a lower court judge and conflicts with a 3rd Circuit ruling, setting up a likely showdown before the Supreme Court.

ACLU lawyer Lee Gelernt said the 9th Circuit ruling clears the way for current and future immigrants to challenge expedited removal orders in federal court.

“The ruling means that thousands of current and future asylum seekers cannot be removed based solely on a cursory review from immigration officials, without a neutral federal court reviewing their case,” Gelernt said.

He said the constitution “does not allow Congress and the president to exclude the courts where an individual’s liberty is at stake, citizen or noncitizen.”

Congress and the president have broad powers over immigration and the Congressional Research Service said in a report last year that the Supreme Court “has repeatedly held” that the government may exclude immigrants without “traditional due process protections.”

But in Thursday’s ruling, the 9th Circuit panel said the expedited removal process violates immigrants’ rights to habeas corpus and the Constitution’s suspension clause, which allows the U.S. government to block detainees’ right to appeal to the courts only during extreme periods such as an invasion or rebellion, to guard against “monarchial power.”

The ruling also cited Boumediene v. Bush, a 2008 Supreme Court ruling that said Guantanamo detainees had a constitutional right to ask a federal judge to review their detention.

The 9th Circuit ruled the decision does not state that Thuraissigiam is entitled to asylum but said it is clear he did not receive a fair hearing.

In the lawsuit, Thuraissigiam had alleged that he had “communication problems” between the asylum officer and the administrative immigration judge who later reviewed his case.

The court said the asylum officer “violated” Thuraissigiam’s rights and deprived him of a “meaningful opportunity” to seek asylum.

Expedited removal proceedings were created under the Illegal Immigration Reform and Immigrant Responsibility Act of 1996, pushed for by Republicans and signed by President Bill Clinton, who also nominated the appeals judges involved in Thursday’s ruling.

Before Trump took office, the speedy process has been applied only to immigrants taken into custody within 100 miles of the border who had been in the country two weeks or less.

In 2017, the Trump administration sought to expand the fast-track process to immigrants who had been in the United States for up to two years, but as of September of last year that had not been implemented, according to the Congressional Research Service.

U.S. Customs and Border Protection did not have updated statistics on expedited removals Thursday, but past estimates have put them in the tens of thousands a year.