A federal judge has blocked the Trump administration from dramatically expanding its power to deport migrants who have illegally entered the United States in the past two years by using a fast-track deportation process that bypasses immigration judges.

In a 126-page ruling, Judge Ketanji Brown Jackson of the U.S. District Court for the District of Columbia issued a nationwide preliminary injunction shortly before midnight Friday, halting enforcement of the administration’s July 23 policy widening application of the “expedited removal” program to undocumented immigrants anywhere in the country who entered over the past two years.

Previously, only migrants caught within 100 miles of the border who illegally had entered within the preceding two weeks were subject to deportation without access to courts or lawyers.

Jackson ruled that the suing immigration advocacy groups, Make the Road New York, LUPE (La Unión del Pueblo Entero) and We Count, were likely to prevail in ongoing litigation and show irreparable harm being suffered by those they represent, including many legal immigrants and asylum seekers who could be swept up and expelled from the country without legal recourse.

“The court’s decision to stop the expansion of this process will protect hundreds of thousands of longtime U.S. residents from being deported without a court hearing and prevents the country from becoming a ‘show me your papers’ regime,” said Trina Realmuto, a directing attorney at the American Immigration Council, which argued the case alongside the American Civil Liberties Union.

Jackson rejected the Department of Homeland Security’s argument that it has authority under immigration law to bypass federal notice and rulemaking requirements, saying it was likely that plaintiffs would be able to prove the sweeping change was “arbitrary and capricious, and therefore unlawful, because DHS failed to address significant flaws in the expedited removal system,” and because it ignored the impact of the expansion “on settled documented noncitizens and their communities.”

The ruling came hours after a federal judge in Los Angeles, U.S. District Judge Dolly M. Gee, separately blocked the Trump administration from implementing rules vastly expanding its ability to detain migrant children with their parents for indefinite periods.

Nearly 300,000 of the approximately 11 million unauthorized immigrants in the United States could be subject to expedited removal, according to the nonpartisan Migration Policy Institute. The typical undocumented immigrant has lived in the United States for 15 years, according to the Pew Research Center.

In announcing the policy in July, acting Department of Homeland Security chief Kevin McAleenan said “the implementation of additional measures is a necessary response to the ongoing immigration crisis.”

In a statement Saturday, a Justice Department spokesman said, “Congress expressly authorized the Secretary of Homeland Security to act with dispatch to remove from the country aliens who have no right to be here. The district court’s decision squarely conflicts with that express grant of authority and vastly exceeds the district court’s own authority.”

Officials said the new strategy responds to an influx of Central Americans and others across the southern border. The change allows the U.S. government to crank up deportations despite huge backlogs in understaffed immigration courts and the high cost of prisonlike detention centers run by Immigration and Customs Enforcement.

Under the new policy, any immigrants apprehended in the United States would have to prove to immigration officials that they have lived inside the country continuously for the past two years, or they could end up in immigration jails, facing summary expulsion.

Immigration lawyers said the unprecedented expansion effectively would make U.S. agents both “judge and prosecutor,” denying immigrants due process before the court or access to lawyers.

“Under this unlawful plan, immigrants who have lived here for years would be deported with less due process than people get in traffic court,” said ACLU Immigrant’s Rights Project director Omar Jadwat.

McAleenan, in a federal notice, wrote that the new rule “will reduce incentives” for migrants to enter the United States without authorization and swiftly move away from the border to avoid the faster deportation process.

Federal officials said they could make exceptions for people with serious medical conditions or “substantial connections” to the United States, and they said deportation would not necessarily be immediate. Officials said they have safeguards for migrants who might be U.S. citizens or legal residents.

Asylum officers will interview immigrants who fear returning to their home countries, to determine whether they qualify for asylum or another form of protection, and officers potentially could refer them to full deportation proceedings. Unaccompanied minors from non-neighboring countries are not eligible for speedy deportations under federal law.

The U.S. government invoked its authority to fast-track deportations of undocumented immigrants who arrived by sea in 2002, after the Sept. 11, 2001, terrorist attacks in New York and Washington. President George W. Bush expanded the program in 2004 to apply to all undocumented immigrants, however they entered the country, who are caught within 14 days within 100 miles of the border. The Bush administration said that issuing removal orders deterred migrants from trying to reenter the United States because that provision made it easier to charge them criminally if they were caught again.

Expedited deportations soared from about 50,000 in 2004 to 193,000 in 2013, about 44 percent of the total number of people deported that year, according to the American Immigration Council.

Since 2017, the caseload in immigration courts has soared to more than 900,000 cases, and ICE has more than 50,000 migrants in custody each day, a record.

In her opinion, Jackson noted that DHS implemented its “New Designation policy” about 2½ years after Trump signed an executive order to expand expedited removals to the fullest extent possible, which he did shortly after his swearing-in, without ever issuing a proposed rule or notice or soliciting public comment.

The Trump administration argued that its new program is exempt from the Administrative Procedure Act’s public-comment requirements and that DHS sought comments on the change when announcing its launch. It said the policy would have taken effect Sept. 1 but told the court it has not yet been applied.