A pair of rulings from federal judges in Hawaii and Maryland effectively prevent President Donald Trump’s new restrictions on travelers from majority-Muslim countries from being enforced.

The courts indicated that Trump’s own statements about Muslims were evidence that the ban is likely unconstitutional.

States, refugee relief organizations and people with ties to the affected countries had sued the Trump administration over the restrictions.

The president vowed to keep defending his executive order and to go to the Supreme Court if necessary.

A federal judge in Hawaii has placed a nationwide hold on key aspects of President Donald Trump’s second attempt at a ban on travel ― a scaled-back version that targeted all non-visa holders from six Muslim-majority countries, as well as a halt on the U.S. refugee resettlement program ― just hours before the new restrictions were to take effect.

U.S. District Judge Derrick Watson said sections of the new travel order likely amounted to a violation of the First Amendment’s establishment clause, which forbids the government from disfavoring certain religions over others.

The ban was scheduled to begin at 12:01 a.m. ET on Thursday, 10 days after Trump signed the revised order. The staggered rollout was designed to give fair warning to those potentially affected ― a contrast from the disorderly implementation of the president’s original executive order, which left thousands of people stranded, detained or with their visas canceled without notice.

Watson gave short shrift to the Trump administration’s argument that the new restrictions applied to a “small fraction” of the world’s 50 predominantly Muslim nations ― and thus could not be read to discriminate against Muslims specifically.

“The illogic of the Government’s contentions is palpable,” Watson wrote in his 43-page decision. “The notion that one can demonstrate animus toward any group of people only by targeting all of them at once is fundamentally flawed.”

The judge also discarded the government’s defense that the text of the new executive order was silent on religion, supposedly solving constitutional defects identified by courts with the first order.

“Any reasonable, objective observer would conclude ... that the stated secular purpose of the Executive Order is, at the very least, secondary to a religious objective of temporarily suspending the entry of Muslims,” Watson wrote.

Trump led a booing audience at a rally in Nashville, Tennessee, Wednesday night in criticizing what he called the “flawed ruling.” The president claimed he has the power to suspend immigration, and slammed what he called “unprecedented judicial overreach.”

“This ruling makes us look weak, which by the way we no longer are,” Trump complained. He added that he would “fight this terrible ruling” in the Supreme Court if necessary. He said the new order “was a watered-down version of the first order” and that he would prefer to go back to the original ― providing more ammunition to opponents’ arguments that, at their core, the two orders are the same.

The Justice Department called the ruling “flawed both in reasoning and in scope.” The president has “lawful authority in seeking to protect our nation’s security,” spokeswoman Sarah Isgur Flores said in a statement.

Trump “should just continue talking, because he is making our arguments for us,” Marielena Hincapié, executive director of the National Immigration Law Center, said on a call with reporters after Trump’s remarks. Her organization was part of a lawsuit in Maryland against the ban.

Early Thursday morning, the federal judge overseeing that separate legal challenge, U.S. District Judge Theodore Chuang, agreed that the tweaks to the new travel order weren’t enough to offset the anti-Muslim sentiments that Trump and his team espoused in fashioning these policies.

“Despite these changes, the history of public statements continues to provide a convincing case that the purpose of the Second Executive Order remains the realization of the long-envisioned Muslim ban,” Chuang wrote in a decision that blocked the new order’s 90-day travel suspension for the six targeted countries ― Iran, Libya, Somalia, Sudan, Syria and Yemen.

The Washington state attorney general’s office, which led the successful challenge to Trump’s first ban, hailed the “teamwork of states” in the “effort to stem the chaos over the past month.” Related legal challenges in Seattle remain pending, and a federal judge there could issue an additional ruling against the new travel restrictions.

The first order, signed on Jan. 27, went into effect immediately, unleashing chaos nationwide. Attorneys and volunteers spent days at airports trying to assist people who had been detained and were being questioned on arrival. Protests erupted in cities around the world. And courts began chipping away at the ban almost as soon as it was implemented.

Of those rulings, the more significant came from federal judge in Seattle, who blocked the entire order in early February, preventing the government from enforcing it anywhere in the country. An appeals court later upheld that ruling, noting that Trump’s ban likely violated the Constitution.

After several delays and false starts, the administration reworked the executive order to create one that would pass muster in the courts ― although Stephen Miller, a senior White House adviser, conceded before it was unveiled that it would have the “same basic policy outcome.” Unlike the first ban, the new version does not apply to current visa holders or to nationals of Iraq, which originally was one of the countries whose nationals were barred for 90 days.

In his decision, Watson singled out that Miller quote, broadcast on Fox News in the days ahead of Trump’s new ban.

The judge also highlighted similar comments by longtime Trump surrogate Rudy Giuliani, who all but admitted on Fox News that the president had asked him look for legal ways to shut out Muslims.

The new order does not single out Syrian refugees for indefinite restriction from entry, and does not include a preference for religious minority refugees, widely viewed as a way to admit Middle Eastern Christians while excluding Muslims.

As drafted, the new order still has the potential to affect tens of thousands of people. Like the now-revoked version, it suspends the refugee resettlement program for at least 120 days and instructs the government to admit up to 50,000 refugees this fiscal year, rather than the goal of 110,000 admissions set by former President Barack Obama. For 90 days, nationals of Iran, Libya, Somalia, Sudan, Syria and Yemen will be barred from the country unless they have a valid visa.

Legal opponents said the new travel ban has the same constitutional defects that courts identified in the first one ― it erects an entry barrier for Muslims on the basis of their faith, a policy choice that Trump promised to carry out as a candidate, but one that national security experts and observers have warned has damaging implications for Americans and refugees both here and abroad.

Those objections aside, Watson suggested that everything is not lost for the Trump administration, and that it could still craft a future policy that aims to protect national security, independent of its misfires.

”Here, it is not the case that the Administration’s past conduct must forever taint any effort by it to address the security concerns of the nation,” the judge wrote. “Based upon the current record available, however, the Court cannot find the actions taken during the interval between revoked Executive Order No. 13,769 and the new Executive Order to be genuine changes in constitutionally significant conditions.”

The government’s likely appeal would go to the U.S. Court of Appeals for the 9th Circuit, the same appellate court that last month refused to allow Trump’s first travel ban from being enforced.

The judges there gave an indication late Wednesday of how they might rule in an upcoming appeal. In a short order issued moments after the Hawaii ruling, a majority of the court’s 25 active judges declined to review a prior ruling in favor of Washington state that kept Trump’s first travel ban on ice.

A longtime member of the court, U.S. Circuit Judge Stephen Reinhardt, wrote separately to commend his colleagues for the decision to leave that ruling in place.

“I am proud to be a part of this court and a judicial system that is independent and courageous, and that vigorously protects the constitutional rights of all, regardless of the source of any efforts to weaken or diminish them,” Reinhardt wrote.

This article has been updated to include comments from Trump and his Justice Department, as well as details from a separate ruling from a federal judge in Maryland and details from the 9th Circuit’s Wednesday order.