A federal judge on Tuesday largely blocked the Trump administration from implementing the latest version of the president's controversial travel ban, setting up yet another legal showdown on the extent of the executive branch's powers when it comes to setting immigration policy.

The decision from U.S. District Judge Derrick K. Watson in Hawaii is sure to be appealed, but for now, it means that the administration cannot restrict the entry of travelers from six of the eight countries that officials said were unable or unwilling to provide information that the United States wanted to vet the countries' citizens.

The latest ban was set to go fully into effect in the early hours of Wednesday, barring various types of travelers from Syria, Libya, Iran, Yemen, Chad, Somalia, North Korea and Venezuela. Watson's order stops it, at least temporarily, with respect to all the countries except North Korea and Venezuela.

In a 40-page decision granting the state of Hawaii's request for a temporary restraining order nationwide, Watson wrote that the latest ban "suffers from precisely the same maladies as its predecessor."

Watson also wrote that the executive order "plainly discriminates based on nationality" in a way that is opposed to federal law and "the founding principles of this Nation."

The White House said in a statement that Watson's "dangerously flawed" order "undercuts the President's efforts to keep the American people safe and enforce minimum security standards for entry into the United States."

"These restrictions are vital to ensuring that foreign nations comply with the minimum security standards required for the integrity of our immigration system and the security of our Nation," the White House said. "We are therefore confident that the Judiciary will ultimately uphold the President's lawful and necessary action and swiftly restore its vital protections for the safety of the American people."

The State Department said that it instructed embassies and consulates across the globe to resume regular processing of visas for people from the six countries but that it would implement the order for those affected from Venezuela and North Korea. Justice Department spokesman Ian Prior said government lawyers would appeal the judge's decision in an "expeditious manner."

"Today's ruling is incorrect, fails to properly respect the separation of powers, and has the potential to cause serious negative consequences for our national security," he said.

Opponents of the ban, though, hailed the judge's ruling. Hawaii Attorney General Douglas Chin said, "Today is another victory for the rule of law. We stand ready to defend it."

Omar Jadwat, who directs the ACLU's Immigrants' Rights Project and was involved in a separate challenge to the ban in federal court in Maryland, said, "We're glad, but not surprised, that President Trump's illegal and unconstitutional Muslim ban has been blocked once again."

Trump was blocked by courts from imposing his last two versions of the travel ban, but the ultimate question of whether he ever had the authority to implement such a measure remains somewhat murky.

The Supreme Court had been scheduled to hear arguments on his second travel ban, inked in March, which barred the entry of citizens from six majority-Muslim countries and refugees from everywhere. But a key portion of that ban expired and Trump issued his latest ban before the hearing.

That prompted the justices to remove oral arguments from the calendar. They later dismissed one of the challenges to the March version of the ban.

Federal appeals courts had ruled against the Trump administration on the last measure, and Watson relied in part on the precedent from one of those cases in the U.S. Court of Appeals for the 9th Circuit. The Supreme Court, though, had vacated the precedent from the other ruling that went against the administration in the U.S. Court of Appeals for the 4th Circuit.

[Latest travel ban will probably affect tens of thousands, and it could short-circuit the court battle]

The state of Hawaii, the International Refugee Assistance Project and others who sued over the March travel ban asked judges to block the new one in federal courts in Hawaii, Washington state and Maryland. They argued that Trump had exceeded his legal authority to set immigration policy and that the latest measure — like the last two — fulfilled his unconstitutional campaign promise to implement a Muslim ban. As of Tuesday afternoon, the judges in Maryland and Washington state had yet to rule, although arguments in Washington are scheduled for Oct. 30.

"It exceeds the limits on the President's exclusion authority that have been recognized for nearly a century, by supplanting Congress's immigration policies with the President's own unilateral and indefinite ban," the challengers in Hawaii wrote of the new ban. "And it continues to effectuate the President's unrepudiated promise to exclude Muslims from the United States."

Hawaii asked a judge to block the ban with respect to all the majority-Muslim countries; the state's lawyers did not challenge the measures imposed against Venezuela and North Korea.

Watson did not address whether the ban was constitutional; rather, he limited his analysis to whether Trump had exceeded the authority Congress has given the president to impose restrictions on those wanting to enter the United States. Of particular concern, he said, were that officials seemed to treat someone's nationality as an indicator of the threat the person poses — without providing evidence of a connection between the two.

Watson said that the order did "not reveal why existing law is insufficient to address the President's described concerns" and that it was internally flawed — for example, by exempting Iraq from the banned list even though Iraq failed the U.S. government's security assessment.

Legal analysts had said challengers of the latest travel ban would face an uphill battle, particularly because the measure was put into effect after an extensive process in which the United States negotiated with other countries for information.

Such a process, legal analysts said, presumably would help the government defeat arguments that the president had not made the appropriate findings to justify his order. The list of countries affected also was changed to include two countries that are not majority Muslim — Venezuela and North Korea — potentially helping the government argue that the measure was not meant to discriminate against Muslims.

Challengers to the ban, however, sought to link the new directive to its predecessors, and they asserted that even the additions were mainly symbolic. The ban only affects certain government officials from Venezuela, and very few people travel to the United States from North Korea each year. They noted that Trump himself promised a "larger, tougher, and more specific" ban — meaning that the new version would have the same legal problems as the earlier iterations.

The directive imposed more complete bans on some countries than on others, and the Trump administration has indicated that countries could make their way off the list if conditions changed.

For Syria and North Korea, the president's proclamation blocked immigrants wanting to relocate to the United States and nonimmigrants wishing to visit in some capacity. For Iran, the proclamation blocked both immigrants and nonimmigrants, although it exempted students and those participating in a cultural exchange.

The proclamation blocked people from Chad, Libya and Yemen from coming to the United States as immigrants or on business or tourist visas, and it blocked people from Somalia from coming as immigrants. The proclamation named Venezuela, but it only blocked certain government officials.

Carol Morello contributed to this report.

Read more:

Almost no North Koreans travel to the U.S., so why ban them?

Trump’s claim that Obama first ‘identified’ the 7 countries in his travel ban

Why did the U.S. travel ban add counterterrorism partner Chad? No one seems quite sure.