A judge has ordered the immediate release of Kilmar Abrego Garcia, who was mistakenly deported in March and brought back to the US to face criminal charges, from immigration custody.

Since Abrego Garcia's return from wrongful detention in El Salvador, he has been re-detained, again without lawful authority, Judge Paula Xinis wrote in her order.

Mr. Abrego Garcia was sent to a prison in El Salvador earlier this year, which the US government later admitted was in error. He was returned to the US to face human smuggling charges and has been held since then.

Judge Xinis also wrote that the government did not have a removal order, which blocks it from deporting Mr. Abrego Garcia at this juncture.

The Trump administration contends Mr. Abrego Garcia is a member of the violent criminal MS-13 gang, which he denies. This spring, the administration flew a large group of migrants it alleged were in the gang to El Salvador's CECOT prison. But a previous court order had barred the US from sending Mr. Abrego Garcia to the country.

Mr. Abrego Garcia also has pleaded not guilty to the smuggling charges, which are part of a trial in Tennessee.

Judge Xinis, who was hearing his challenge to deportation in a federal court in Maryland, said he must now follow the conditions of his release from jail in Tennessee.