A federal judge in California has temporarily blocked the Trump administration from refusing asylum to migrants who cross the US southern border illegally, marking a significant blow to the president’s crackdown on immigration.

Trump signed a proclamation on 9 November declaring that people who crossed the border between official US ports of entry would be ineligible for asylum. The move was among the most audacious in the administration’s anti-immigrant agenda as federal laws enshrine the right to claim asylum irrespective of how an individual enters the country. The president had cited a threat to national security amid heightened rhetoric on a number of migrant caravans heading towards the US.

But in his ruling on Monday evening, US district judge Jon Tigar said Trump did not have the authority to override the current legislation. He also ruled the president had misused his authority to issue emergency regulations and waive a 30-day waiting period to consider comments on the policy change.

“Whatever the scope of the president’s authority, he may not rewrite the immigration laws to impose a condition that Congress has expressly forbidden,” said Tigar, who sits in the northern district of California and was nominated in 2012 by President Barack Obama.

On Tuesday morning the administration hit back, vowing to challenge Tigar’s order and branding it “absurd” to side with the civil rights groups who brought the case who had stopped “the entire federal government from acting so that illegal aliens can receive a government benefit to which they are not entitled”.

“We look forward to continuing to defend the Executive Branch’s legitimate and well-reasoned exercise of its authority to address the crisis at our southern border,” Trump’s justice department said.

In a statement laden with anti-migrant rhetoric, the White House said the ruling would “open the floodgates” to “countless illegal aliens” branding the decision “yet another example of activist judges imposing their open borders policy preferences”.

The Department of Homeland Security (DHS) did not immediately comment on the ruling, a temporary restraining order, which will remain in effect for one month unless it is overturned. In issuing the ban, Trump used the same powers he used last year to impose a travel ban that was eventually upheld by the supreme court after it was refined three times and blocked by numerous lower courts.

If it is eventually enforced, the ban would make it harder for thousands of people to avoid deportation. The DHS estimates that 70,000 people a year claim asylum between official ports of entry, including a rising number of families and unaccompanied minors fleeing violence in Central America.

Baher Azmy, a lawyer for the Center for Constitutional Rights, which sued the government alongside the American Civil Liberties Union (ACLU), said: “Individuals are entitled to asylum if they cross between ports of entry. It couldn’t be clearer.”

About 3,000 people from the first of the caravans have arrived in Tijuana, Mexico, across the border from San Diego, California. US Customs and Border Protection said on Monday it closed off northbound traffic for several hours at the San Ysidro crossing. It has also installed movable wire-topped barriers, apparently to stop a potential rush of people.

As of Monday, 107 people detained between official crossings have sought asylum since Trump’s order came into effect, according to the DHS, which oversees Customs and Border Protection. Officials did not say whether those people’s cases were still progressing through the other, more difficult avenues available to them after the proclamation.

The administration had insisted the order would push asylum seekers to make their claims at official border crossings. But at many locations the order had resulted in long wait times and, according to advocates, many people including unaccompanied minors being turned away before they could make their claim.

Following the ruling, issued late on Monday night, the ACLU attorney Lee Gelerent, who had argued against the ban in court earlier in the day, said: “This ban is illegal, will put people’s lives in danger, and raises the alarm about President Trump’s disregard for separation of powers. There is no justifiable reason to flatly deny people the right to apply for asylum.”

Trump issued the proclamation shortly after the midterm elections, during which he ratcheted up anti-immigrant rhetoric on the campaign trail and invoked conspiracy theories about migrant caravans thousands of miles from the US.

The radical restrictions were part of a drive to curtail immigration to the US, which led to the family separation crisis this year and a policy banning migrants from several Muslim-majority countries.