– A federal judge in Hawaii blocked most of President Donald Trump’s latest travel ban Tuesday, just hours before it was set to take effect, saying the revised order “suffers from precisely the same maladies as its ­predecessor.”

It was the third set of travel restrictions issued by the president to be thwarted, in whole or in part, by the courts.

U.S. District Judge Derrick Watson issued the ruling after the ban on a set of mostly Muslim countries was challenged by the state of Hawaii, which warned that the restrictions would separate families and undermine the recruiting of 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 against Trump’s previous ban.

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 applies only to the six Muslim-majority countries on the list. It 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.

Watson noted that Hawaii argues Trump hasn’t backed down on calls for a ban on Muslim immigration. Watson cited Trump’s series of June tweets “in which [Trump] complained about how the Justice Department had submitted a ‘watered down, politically correct version’ to the Supreme Court.”

Other courts that weighed the travel ban have cited Trump’s comments about banning Muslims from entering the United States.

The Fourth U.S. Circuit Court of Appeals in Richmond, Va., said a previous version of the ban was “rooted in religious animus” toward Muslims and pointed to Trump’s campaign promise to impose a ban on Muslims entering the country, as well as tweets and remarks he has made since becoming president.

In Greenbelt, Md., U.S. District Judge Theodore Chuang called Trump’s own statements about barring Muslims from entering the United States “highly relevant.”