Judges in Hawaii and Maryland have blocked Donald Trump's revised travel ban from taking effect as scheduled, using the US president's own words as evidence that the order discriminates against Muslims.
The rulings in Hawaii late on Wednesday and in Maryland early on Thursday were victories for civil liberties groups and advocates for immigrants and refugees, who argued that a temporary ban on travel from six predominantly Muslim countries violated the First Amendment.
The Trump administration argued that the ban was intended to protect the United States from terrorism.
In Greenbelt, Maryland, US District Judge Theodore Chuang - who was appointed by then-president Barack Obama - called Mr Trump's own statements about barring Muslims from entering the US "highly relevant".
The second executive order removed a preference for religious minorities from the affected countries, among other changes that the Justice Department argued would address the legal concerns surrounding the first ban, which was also blocked in court.
"Despite these changes, the history of public statements continues to provide a convincing case that the purpose of the second executive order remains the realisation of the long-envisioned Muslim ban," Judge Chuang said.
The initial ban sparked chaos at US airports and widespread criticism around the world when it was signed in January.
It was later blocked by a judge in Washington state, a ruling that was upheld by the 9th US Circuit Court of Appeals.
In Honolulu, US District Judge Derrick Watson criticised what he called the "illogic" of the government's arguments and cited "significant and unrebutted evidence of religious animus" behind the travel ban.
He also noted that while courts should not examine the "veiled psyche" and "secret motives" of government decision-makers, "the remarkable facts at issue here require no such impermissible inquiry".
Judge Watson also wrote, referring to a statement Mr Trump issued as a candidate: "For instance, there is nothing 'veiled' about this press release: 'Donald J. Trump is calling for a total and complete shutdown of Muslims entering the United States'."
The case was argued in court by acting US Solicitor General Jeffrey Wall, who said the ban "doesn't say anything about religion. It doesn't draw any religious distinctions".
Speaking on Wednesday evening at a rally in Nashville, Tennessee, Mr Trump called the ruling in Hawaii an example of "unprecedented judicial overreach" and said his administration would challenge it at the US Supreme Court.
He also called his new travel ban a watered-down version of the first one, which he said he wished he could implement.
"We're going to win. We're going to keep our citizens safe," the president said. "The danger is clear. The law is clear. The need for my executive order is clear."
While the Hawaii order only halts the ban temporarily, Judge Chuang's ruling in Maryland took the form of a preliminary injunction, which will remain in effect indefinitely as the case is litigated.
Judge Chuang was also the first judge to stop the ban outside the 9th Circuit, which has a liberal reputation.
"Unless and until the president realises that this is a battle in which he's going to keep losing and decides to do the right thing and abandon this course, for as long as he's on it we'll keep litigating it and I think we're going to keep winning," said Omar Jadwat, who argued the case for the American Civil Liberties Union in Maryland.
Judge Chuang did not block the entire executive order, saying the plaintiffs did not sufficiently develop their argument that a temporary ban on refugees discriminates on the basis of religion.
Plaintiffs in the Maryland case had also sought to stop a portion of the order that would reduce the number of refugees allowed to enter the country this fiscal year from 110,000 to 50,000.
Still, the judge's order is hugely meaningful for many plaintiffs, including a man in Texas whose same-sex fiance is seeking a visa to enter the United States from Iran, said Justin Cox, a lawyer with the National Immigration Law Centre who also argued the Maryland case.
"This Muslim ban was threatening to either separate or continue to separate families who've already been separated for months and years," Mr Cox said.
"It has real-world consequences and we were obviously very glad to see that Judge Chuang recognised those and rejected the government's frankly callous argument that our clients have already been waiting and another few months couldn't possibly be irreparable."
If the administration appeals against Judge Watson's decision at the 9th Circuit level, the matter would be heard by different judges from the three who ruled on the case last month.
That is because the panel of judges assigned to such cases rotates every month, said court spokesman David Madden.
The 9th Circuit on Wednesday declined to reconsider the 3-0 decision not to reinstate the original ban.
In a dissent, five judges said they considered that decision incorrect and wanted it vacated.
The hearings in Maryland and Hawaii were two of three held on Wednesday in federal courts around the country.
US District Judge James Robart in Seattle, who blocked the initial travel ban last month, did not immediately rule on a request from an immigrant rights group to block the revised version.
In all, more than half a dozen states are trying to stop the ban.