A federal judge on Wednesday blocked Trump administration policies that prevented immigrants who suffered gang violence or domestic abuse in their home countries from seeking asylum.

Emmet Sullivan, a US district court judge, declared that some of the guidance that the then attorney general, Jeff Sessions, issued this year cannot be used to determine whether an immigrant has a credible fear of persecution or torture in their home countries, the first step to making an asylum claim in the US.

It was yet another legal blow for Donald Trump’s efforts to harden immigration policies without Congress changing laws. The judge said the administration’s policy on asylum seekers violates federal immigration law and that “it is the will of Congress – not the whims of the executive” that sets the standards for expedited removal.

A further rebuke to Trump’s efforts came from a US judge in San Francisco who on Wednesday extended his decision blocking the Trump administration from enforcing a ban on asylum for any immigrants who illegally cross the US-Mexico border. Judge Jon Tigar ruled in favor of keeping the ban on hold pending the outcome of a lawsuit challenging it. The case could take months to resolve. He had previously blocked the ban for 30 days.

The ban conflicts with an immigration law that says immigrants can apply for asylum regardless of how they enter the US, Tigar said.

The administration has asked the supreme court to allow that asylum policy to go forward.

Responding to Sullivan’s ruling, a justice department spokesman, Steven Stafford, said Sessions’ guidance had followed the requirements for asylum under US law. “We are reviewing our options with regard to this ruling, and we will continue to restore the rule of law in our immigration system,” he said.

Trump administration officials say the asylum process is being exploited by immigrants who are counting on passing the initial credible-fear screening and being released into the country. Only about 9% of all people who initially claim asylum are granted it, and tens of thousands of families from Central America are coming to the US every month.

The immigration policy change had an immediate impact. Immigration lawyers say people whom they expected would pass credible-fear screenings began to fail them, and lawyers say immigration judges are signing off on more denials during appeals, effectively ending what could have been a years-long asylum process before it began.

But Trump officials also say the number of people claiming credible fear has risen dramatically.

Asylum can be granted to people who were persecuted in their home country or could be persecuted if forced to return. Thousands of people seek asylum each month at US Customs and Border Protection stations along the south-west border.

The American Civil Liberties Union sued the government over the 11 June change on behalf of 12 parents and children who were wrongly found not to have a credible fear of return. Sullivan’s ruling impacts thousands of cases where immigrants are in expedited removal proceedings.

Among the plaintiffs was a woman identified only by a pseudonym, Grace. The ACLU said Grace’s partner beat her and her children, and sexually assaulted her and her daughter. Once, the ACLU says, her daughter suffered a miscarriage after he attacked her. The lawsuit says police did not act when she contacted them. The lawsuit says Grace was found not to have a credible fear of persecution.

The judge also ordered the government to return any of the plaintiffs who may have been deported back to the US, and prevent further deportations.

“This ruling is a defeat for the Trump administration’s all-out assault on the rights of asylum seekers. The government’s attempt to obliterate asylum protections is unlawful and inconsistent with our country’s longstanding commitment to provide protection to immigrants fleeing for their lives,” said Jennifer Chang Newell, managing attorney of the ACLU’s Immigrants’ Rights Project, who argued the case.

The judge who issued the ruling attracted attention one day earlier for his public excoriation of the former Trump administration adviser Michael Flynn, saying he felt disgusted and disdainful of Flynn’s crimes. He allowed Flynn to postpone his sentencing so Flynn could continue cooperating with investigators and get credit that could allow him to avoid prison.