The Trump administration’s policy to prohibit migrants from seeking asylum unless they come into the United States through a designated port of entry was rejected by a federal judge on Friday, the latest loss the White House has faced in the courts.

The administration was trying to stop those crossing the southern border illegally -- outside a designated port of entry -- from applying for asylum.

But U.S. District Judge Randolph Moss in Washington, D.C., ruled that the policy was unlawful and “in excess of statutory … authority.”

The judge said that while Congress grants the U.S. Department of Homeland Security secretary the authority to create additional restrictions on asylum policy, those limitations still must fit within the confines of the law as established by Congress.

Trump has launched multiple efforts to limit asylum, including a new controversial rule that was announced and immediately challenged just last month.

That rule aimed to further limit who could apply for asylum at the U.S.-Mexico border by attempting to force migrants to apply for asylum in a third country if they were passing through before applying upon arrival in the United States.

If a migrant failed to do this, per the rule, their asylum claim would be denied and they would be immediately deported.

A migrant “who enters or attempts to enter the United States across the southern border after failing to apply for protection in a third country outside the alien’s country of citizenship, nationality, or last lawful habitual residence through which the alien transited en route to the United States is ineligible for asylum,” according to the rule.