Trump invoked earlier the Alien Enemies Act of 1798 against the group saying the country was facing an "invasion" from a criminal organisation that has been linked to kidnapping, extortion, organised crime and contract killings.
Hours afterwards, Judge James Boasberg issued a temporary restraining order for 14 days.
Boasberg said the act "does not provide a basis for the president's proclamation given that the terms invasion, predatory incursion really relate to hostile acts perpetrated by any nation and commensurate to war."
In invoking the act, Trump said members of the gang were "conducting irregular warfare and undertaking hostile actions against the United States" with the goal of destabilising the nation.
The act, which has only been used in times of war, could allow the president to bypass the due process rights of migrants categorised as threats and rapidly deport them.
While the proclamation was released by the White House on Saturday, the wording suggests Trump signed it on Friday.
Under Trump's proclamation, all Venezuelan citizens 14 years of age or older who are determined to be members of the gang, are within the US, and are not naturalised or lawful permanent residents of the country are "liable to be apprehended, restrained, secured, and removed as Alien Enemies".
The Alien Enemies Act is best known for its use to justify internment camps for people of Japanese, German and Italian descent during World War Two.
The Trump administration in February designated Tren de Aragua, the Sinaloa Cartel and six other criminal groups as global terrorist organisations.
Saturday's directive said that Tren de Aragua "has engaged in and continues to engage in mass illegal migration to the United States to further its objectives of harming United States citizens".
Trump made the threat posed by the gang a regular feature of his campaign speeches as evidence of what he called a spike in "migrant crime".
Numerous studies show immigrants do not commit crimes at higher rates than native-born Americans.
"Invoking the Alien Enemies Act, an extraordinary wartime power with a shameful history, to arbitrarily detain and deport immigrants is bigoted, dangerous, and profoundly unjust," said New York Attorney General Letitia James.
William Vasquez, a immigration lawyer in North Carolina, posted on social media that this is the first time the act "has been applied against migrants from a country with which the US is not at war".
Trump's action after Boasberg earlier on Saturday temporarily blocked the US government from deporting five Venezuelans after two non-profit groups sued saying invocation of the act would be illegal as it has only been "a power invoked in a time of war, and plainly only applies to warlike actions".
The court granted a temporary restraining order, stopping the government from deporting them for 14 days. The American Civil Liberties Union, one of the groups that brought the suit, said the Venezuelans are seeking asylum and have been misidentified as being part of Tren de Aragua.
with AP