HONOLULU — A federal judge in Hawaii blocked the Trump administration Tuesday from enforcing its latest travel ban just hours before it was set to take effect, saying the president's revised order "suffers from precisely the same maladies as its predecessor."

It was the third set of travel restrictions issued by President Donald Trump to be thwarted in some way by the courts.

U.S. District Judge Derrick Watson issued the ruling after the ban was challenged by the state of Hawaii, which warned that the restrictions would separate families and undermine the recruiting of diverse college students.

White House spokeswoman Sarah Huckabee Sanders called the ruling "dangerously flawed" and said it "undercuts the president's efforts to keep the American people safe." The Justice Department said it will quickly appeal.

At issue was a ban, announced in September and set to go into effect early Wednesday, on travelers from Chad, Iran, Libya, North Korea, Somalia, Syria and Yemen, along with some Venezuelan government officials and their families.

The Trump administration said the ban was based on an assessment of each country's security situation and willingness to share information with the U.S.

Watson, appointed to the bench by President Barack Obama, said the new restrictions ignore a federal appeals court ruling that found Trump's previous ban exceeded the scope of his authority.

The latest version "plainly discriminates based on nationality in the manner that the 9th Circuit has found antithetical to ... the founding principles of this nation," Watson wrote.

The judge's ruling does not affect the restrictions against North Korea or Venezuela, because the state of Hawaii did not ask for that.

"This is the third time Hawaii has gone to court to stop President Trump from issuing a travel ban that discriminates against people based on their nation of origin or religion," Hawaii Attorney General Doug Chin said in a statement. "Today is another victory for the rule of law."

Hawaii argued the updated ban was a continuation of Trump's campaign call for a ban on Muslims, despite the addition to the list of two countries without a Muslim majority.

In his ruling, the judge said the new ban, like its predecessor, fails to show that nationality alone makes a person a greater security risk to the U.S.

"The categorical restrictions on entire populations of men, women and children, based upon nationality, are a poor fit for the issues regarding the sharing of 'public-safety and terrorism-related information' that the president identifies," Watson said.

He also said the ban in inconsistent in the way some countries are included or excluded.

The judge said he would set an expedited hearing to determine whether his temporary restraining order blocking the ban should be extended.

Other courts are weighing challenges to the ban.

In Maryland, the American Civil Liberties Union and other groups are seeking to block the visa and entry restrictions. Washington state, Massachusetts, California, Oregon, New York and Maryland are challenging the order in front of the same federal judge in Seattle who struck down Trump's initial ban in January.

That ban — aimed mostly at Muslim-majority countries — led to chaos and confusion at airports nationwide and triggered several lawsuits, including one from Hawaii.

When Trump revised the ban, Hawaii challenged that version, too, and Watson agreed it amounted to discrimination based on nationality and religion. A subsequent U.S. Supreme Court ruling allowed the administration to partially reinstate restrictions on Iran, Libya, Somalia, Sudan, Syria and Yemen and all refugees.

Hawaii then successfully challenged the government's definition of which family members of people already living in the U.S. would be allowed into the country, and Watson ordered the list expanded.