A federal judge has ruled Donald Trump cannot prevent asylum being granted to people illegally entering the US from Mexico
The US president had said only those entering the country at official ports of entry should be able to get asylum, not those who sneaked across the southern border.
Civil liberties groups went to court to fight the ban and Judge Jon Tigar agreed with them, saying any foreigners arriving in the US could apply for asylum.
This right was stated in the 1965 Immigration and Nationality Act (INA) and remained "whether or not [they arrived] at a designated port of arrival", he added.
"The rule barring asylum for immigrants who enter the country outside a port of entry irreconcilably conflicts with the INA and the expressed intent of congress," he wrote.
"Whatever the scope of the president's authority, he may not rewrite the immigration laws to impose a condition that congress has expressly forbidden."
He said immigrants would "suffer irreparable injury" and asylum seekers would be "put at increased risk of violence and other harms at the border" and many would be deprived of "meritorious" claims.
The judge's ruling will remain in effect for one month, with another hearing scheduled in December to consider arguments for a permanent order.
Mr Trump said on 9 November that anyone who crossed the southern border between official ports of entry would not be eligible for asylum.
He was spurred on by the approach of several migrant caravans, with thousands of people who he said included "criminals" and "very bad thugs and gang members".
At court, representatives of the Trump administration said the president had the executive power to preserve national security by cutting immigration.
He used the same power last year in a ban on travellers from mainly Muslim countries, a law which was upheld by the US Supreme Court in June after a long legal battle.
Mr Trump's representatives had also argued the president's rule was "consistent with" the law because, while it stopped claimants from getting asylum, it did not stop them from applying for it – an argument Judge Tigar said "strains credulity".
More from US
The Department of Homeland Security has said 70,000 people a year claim asylum between official ports of entry.
Lee Gelernt, a lawyer for the American Civil Liberties Union, said: "We don't condone people entering between ports of entry, but congress has made the decision that if they do, they still need to be allowed to apply for asylum."