The judge also said the men, expelled under the Alien Enemies Act, were likely to prevail in their claims that they had been treated unfairly, deported with no chance to contest their removals.
A federal judge in Washington ordered the Trump administration on Wednesday to take steps toward giving nearly 140 Venezuelan immigrants who were deported to El Salvador in March under a rarely invoked wartime law the due process that they had been denied.
In a sweeping and at times outraged opinion, the judge, James E. Boasberg, compared the expelled men to characters in a Kafka novel. Judge Boasberg also asserted that they were likely to prevail in their claims that President Trump had treated them unfairly by deporting them without hearings to a brutal Salvadoran prison under the expansive powers of the wartime statute, known as the Alien Enemies Act.
Judge Boasberg did not weigh in on the question of whether Mr. Trump had invoked the act lawfully when he expelled the men, who are accused of being members of the street gang Tren de Aragua, to the prison in El Salvador on March 15. He simply asserted that the White House had stripped them of their rights by not allowing them to contest their deportations before they were flown into the custody of jailers at the so-called Terrorism Confinement Center, also known as CECOT.
“Perhaps the president lawfully invoked the Alien Enemies Act,” Judge Boasberg wrote. “Perhaps, moreover, defendants are correct that plaintiffs are gang members. But — and this is the critical point — there is simply no way to know for sure, as the CECOT plaintiffs never had any opportunity to challenge the government’s say-so.”
Instead, Judge Boasberg continued, Trump officials “spirited away planeloads of people before any such challenge could be made. And now, significant evidence has come to light indicating that many of those currently entombed in CECOT have no connection to the gang and thus languish in a foreign prison on flimsy, even frivolous, accusations.”
The 69-page ruling by Judge Boasberg was the latest flashpoint in a monthslong legal battle between the American Civil Liberties Union, which has been defending the Venezuelan men, and administration officials, who have sought time and again to use the Alien Enemies Act to deport people accused of belonging to Tren de Aragua with as little friction as possible.
Federal courts around the country have been divided on the issue of whether Mr. Trump has properly invoked the law, which was first passed in 1798 and is meant to be used only in times of declared war or during an invasion by a hostile foreign nation.
A federal appeals court in New Orleans is set to hear arguments on that question at the end of the month in a case that is likely to end up at the Supreme Court. The justices have already decided that the White House failed to give immigrants ample opportunity to challenge their removals under the act, but they have not yet issued an opinion on whether Mr. Trump’s claims that the presence of Tren de Aragua in the United States is tantamount to an invasion and that its members have been acting at the behest of a hostile Venezuelan government comport with reality.
The A.C.L.U. hailed Judge Boasberg’s decision.
“The court correctly held that the government cannot send people to a brutal foreign prison without any due process and then decline all responsibility to remedy the blatant constitutional violation,” said Lee Gelernt, the lead lawyer for the A.C.L.U.
The case in front of Judge Boasberg is unique. It is the sole legal proceeding in which the A.C.L.U. is trying not to prevent immigrants who are still in the United States from being expelled under the act, but rather is seeking to get due process for those who have already been deported under its powers to El Salvador.
The history of the case is fraught: The administration flew the 137 Venezuelan men in question to El Salvador from an airport in Texas even as Judge Boasberg was holding a hastily convened virtual hearing to consider the question of whether their removals were lawful.
The judge ordered the planes to be turned around midair, but officials failed to comply. He has since threatened to open an investigation into whether contempt sanctions are warranted, but the federal appeals court in Washington that sits over him has temporarily placed that inquiry on hold.
In many ways, Judge Boasberg’s ruling raised as many questions as it answered. While he told the administration that it must “facilitate” the ability of the men being detained in El Salvador “to contest their removal” under the Alien Enemies Act, he put off for the moment the thorny issue of “what such facilitation must entail.”
The A.C.L.U. had requested a more robust solution, asking Judge Boasberg to order the government to facilitate the return of the men to the United States. But the judge said he intended to “proceed in measured fashion,” beginning by allowing Trump officials to propose how the men being held at the Terrorism Confinement Center should receive the due process to which they are “constitutionally due.”
The Justice Department, representing the White House, had tried to avoid responsibility altogether for the deported men, arguing that they were in Salvadoran, not American, custody and thus were beyond the reach of the U.S. judicial system.
In his ruling, Judge Boasberg said that while it was “a close question,” he agreed with the government’s position. He asserted that the facts in the case appeared to show that “the United States and El Salvador have struck a diplomatic bargain vis-à-vis the detainees” and that he could not second-guess that arrangement — even though, as he acknowledged, several top Trump officials had made public statements that the administration was deeply involved in the plans to hold the men at the terrorism center.
Still, Judge Boasberg said the White House had a legal duty to give the men it had summarily expelled to El Salvador the due process they had been denied. While the judge conceded that the White House had expansive powers to conduct foreign affairs, he maintained that officials had to “right their legal wrongs.”
“Absent this relief,” he wrote, “the government could snatch anyone off the street, turn him over to a foreign country and then effectively foreclose any corrective course of action.”