HONOLULU -- Hours before it was to take effect, President Donald Trump's revised travel ban was put on hold Wednesday by a federal judge in Hawaii who questioned whether the administration was motivated by national security concerns.

U.S. District Judge Derrick Watson also said Hawaii would suffer financially if the executive order blocked the flow of students and tourists to the state, and he concluded that Hawaii was likely to succeed on a claim that the ban violates First Amendment protections against religious discrimination.

"The illogic of the government's contentions is palpable," Watson wrote. "The notion that one can demonstrate animus toward any group of people only by targeting all of them at once is fundamentally flawed."

Trump called the ruling an example of "unprecedented judicial overreach" and said his administration would appeal it to the U.S. Supreme Court.

"We're going to win. We're going to keep our citizens safe," the president said at a rally in Nashville. "The danger is clear. The law is clear. The need for my executive order is clear."

The judge issued his 43-page ruling less than two hours after hearing Hawaii's request for a temporary restraining order to stop the ban from being put into practice.

The ruling came as opponents renewed their legal challenges across the country, asking judges in three states to block the executive order that targets people from six predominantly Muslim countries. Federal courts in Maryland, Washington state and Hawaii heard arguments Wednesday about whether it should be allowed to take effect early Thursday as scheduled.

In all, more than half a dozen states are trying to stop the ban.

Watson made it clear that his decision applied nationwide, ruling that the ban could not be enforced at any U.S. borders or ports of entry or in the issuance of visas.

Nominated to the federal bench by President Barack Obama in 2012, he is currently the only Native Hawaiian judge serving on the federal bench and the fourth in U.S. history. He received his law degree from Harvard in 1991.

In Maryland, attorneys told a federal judge that the measure still discriminates against Muslims.

Government attorneys argued that the ban was revised substantially to address legal concerns, including the removal of an exemption for religious minorities from the affected countries.

"It doesn't say anything about religion. It doesn't draw any religious distinctions," said Jeffrey Wall, who argued for the Justice Department.

Attorneys for the ACLU and other groups said that Trump's statements on the campaign trail and statements from his advisers since he took office make clear that the intent of the ban is to ban Muslims. Trump policy adviser Stephen Miller has said the revised order was designed to have "the same basic policy outcome" as the first.

The new version of the ban details more of a national security rationale. It is narrower and eases some concerns about violating the due-process rights of travellers.

It applies only to new visas from Somalia, Iran, Syria, Sudan, Libya and Yemen and temporarily shuts down the U.S. refugee program. It does not apply to travellers who already have visas.

"Generally, courts defer on national security to the government," said U.S. District Judge Theodore Chuang. "Do I need to conclude that the national security purpose is a sham and false?"

In response, ACLU attorney Omar Jadwat pointed to Miller's statement and said the government had put out misleading and contradictory information about whether banning travel from six specific countries would make the nation safer.

The Maryland lawsuit also argues that it's against federal law for the Trump administration to reduce the number of refugees allowed into the United States this year by more than half, from 110,000 to 50,000. Attorneys argued that if that aspect of the ban takes effect, 60,000 people would be stranded in war-torn countries with nowhere else to go.

Chuang made no immediate ruling.

In the Hawaii case, the federal government said there was no need to issue an emergency restraining order because Hawaii officials offered only "generalized allegations" of harm.

Jeffrey Wall of the Office of the Solicitor General challenged Hawaii's claim that the order violates due-process rights of Ismail Elshikh as a U.S. citizen who wants his mother-in-law to visit his family from Syria. He says courts have not extended due-process rights outside of a spousal relationship.

Neal Katyal, a Washington, D.C., attorney representing Hawaii, called the story of Elshiskh, an Egyptian immigrant and naturalized U.S. citizen, "the story of America."

In Washington state, U.S. District Judge James Robart -- who halted the original ban last month -- heard arguments in a lawsuit brought by the Northwest Immigrant Rights Project, which is making arguments similar to the ACLU's in the Maryland case.

Robart said he is most interested in two questions presented by the group's challenge to the ban: whether the ban violates federal immigration law, and whether the affected immigrants would be "irreparably harmed" should the ban go into effect.

He spent much of Wednesday's hearing grilling the lawyers about two seeming conflicting federal laws on immigration -- one that gives the president the authority to keep "any class of aliens" out of the country, and another that forbids the government from discriminating on the basis of nationality when it comes to issuing immigrant visas.

Robart said he would issue a written order, but he did not say when. He is also overseeing the challenge brought by Washington state.

Attorney General Bob Ferguson argues that the new order harms residents, universities and businesses, especially tech companies such as Washington state-based Microsoft and Amazon, which rely on foreign workers. California, Maryland, Massachusetts, New York and Oregon have joined the claim.

------

Johnson reported from Seattle. Associated Press Writer Ben Nuckols in Greenbelt, Maryland, also contributed to this report.