Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A federal judge in Hawaii blocked enforcement of President Donald Trump's revised executive order on entry into the United States on Wednesday, just hours before it was to have taken effect.

The ruling, granting a request for a temporary restraining order by the state of Hawaii and Ismail Elshikh, stalls the president's second attempt to suspend admission of nearly all refugees for 120 days and to restrict visas for nationals from Iran, Libya, Somalia, Sudan, Syria and Yemen for 90 days.

U.S. District Judge Derrick Watson, who said the restraining order applies nationwide, said Trump's travel order was religiously discriminatory.

In an appearance Wednesday night in Nashville, Tennessee, Trump denounced the ruling as "an unprecedented judicial overreach" and said his administration would pursue the case all the way to the Supreme Court if necessary.

"We're talking about the safety of our nation, the safety and security of our people," he said, adding: "This ruling makes us look weak."

Related: Trump Blasts Judge's Immigration Ruling, Takes Shot at Clinton

Sarah Isgur Flores, a spokeswoman for the Justice Department, called Watson's ruling "flawed both in reasoning and in scope," saying Trump's travel order "falls squarely within his lawful authority in seeking to protect our nation's security."

Watson, whom President Barack Obama appointed to the district court in 2013, didn't formally rule on the constitutionality of Trump's order itself. Critics, including Hawaii Attorney General Doug Chin, have called it a thinly veiled unconstitutional "Muslim ban," which Trump has denied.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

But Watson wrote that he believed Hawaii had a "strong likelihood of success on the merits" in its attempt to overturn Trump's order on religious grounds.

The court record, according to Watson, shows "significant and unrebutted evidence of religious animus," in violation of the Constitution.

Watson cited public statements by Trump that he said proved that the order was targeted at Muslims — including his comments after he signed the first executive order in January that he was "establishing a new vetting measure to keep radical Islamic terrorists out of the United States of America" because "we don't want them here."

The court record shows "significant and unrebutted evidence of religious animus."

Watson also cited remarks by former New York Mayor Rudy Giuliani, a prominent Trump supporter, who said in January: "When he [Trump] first announced it, he said, 'Muslim ban.' He called me up. He said, 'Put a commission together. Show me the right way to do it legally.'"

"A reasonable, objective observer — enlightened by the specific historical context, contemporaneous public statements, and specific sequence of events leading to its issuance — would conclude that the Executive Order was issued with a purpose to disfavor a particular religion," Watson wrote.

Chin said the public statements by Trump and his associates were crucial to the decision.

"Clearly [Watson] was very focused on a lot of what had been said beforehand," Chin said at a news conference in Honolulu on Wednesday night.

Ellen Rosenblum, the attorney general of Oregon, one of 13 other states to file briefs in support of Hawaii's motion, agreed, saying: "An intent is an intent. You cannot snap your fingers and make an intent go away."

In addition to Honolulu, hearings on similar requests were held Wednesday in U.S. District Court in Bethesda, Maryland, and in Seattle, where judges didn't immediately issue any rulings.

A Maryland judge Thursday morning issued a temporary injunction nationwide against Trump's order.

Washington Attorney General Bob Ferguson, whose office challenged the initial executive in a lawsuit that resulted in its being blocked, called the Hawaii ruling "fantastic news" on Twitter.

AG Ferguson describes "fantastic news" out of Hawaii. — WA Attorney General (@AGOWA) March 15, 2017

Elshikh, Hawaii's co-plaintiff, is a legal U.S. resident, but his mother-in-law, who is Syrian, would have been barred from legally entering the United States under the president's order. He and the state argued that Trump's order would discriminate on the basis of nationality and would harm tourism and recruitment of foreign workers.

In the Maryland hearing, refugees' advocates and civil liberties groups also argued that the order would discriminate against Muslims, "stigmatizing and demeaning one religious group."

Trump's first order in late January caused chaos at airports, with students, professors and green card holders among those reporting that they were turned away or detained and were subjected to lengthy travel delays and questioning.

The federal judge in Seattle, James Robart, blocked the order in a Feb. 3 ruling, and an appeals court refused to reinstate it. Trump issued the order on March 6.

It removed Iraq from the list of affected countries and exempted lawful permanent residents and green card holders. It also dropped a provision that would have indefinitely suspended admission to the United States of refugees from Syria. Trump has said the restrictions were necessary to protect Americans from terrorism.