A federal judge in Hawaii on Wednesday issued a nationwide halt to President Trump's temporary travel ban targeting six majority-Muslim countries. It was a stinging rebuke of Trump's second attempt to institute the controversial order just hours before it was to take effect.

U.S. District Judge Derrick Watson issued a temporary restraining order against Trump's ban, saying he would reject any immediate appeals by the government.

Watson wrote in his ruling that the federal government had not proved that the ban was needed to protect the U.S. from terrorists trying to infiltrate the country through legal immigration or the refugee program, citing a "dearth of evidence indicating a national security purpose." He wrote that despite changes made by the White House to the new ban, it clearly violated constitutional protections of religion.

"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 in spite of its stated, religiously-neutral purpose," Watson wrote.

The reaction from lawyers battling Trump's order was swift.

"Aloha TRO," said Karen Tumlin, legal director for the National Immigration Law Center, referring to the legal shorthand for a temporary restraining order. "This finds, based on constitutional grounds, that indeed the new executive order, just like the first executive order, meant to enact a state policy denigrating Muslims."

Trump's second attempt to limit travel from those countries had at 12:01 ET Thursday effective date. A group of states, immigration and refugee advocacy groups, and private residents filed lawsuits to block the new ban from going into effect, as happened when Trump issued his first travel ban in late January.

Judges in Hawaii, Maryland and Washington state heard arguments on those legal challenges, with Hawaii being the first to issue a ruling.

The executive order, signed by Trump on March 6, bars citizens of Iran, Libya, Somalia, Sudan and Syria for 90 days and all refugees for 120 days. It includes several changes from the original ban struck down in court.

Iraq was removed from the list after its government agreed to enhanced screening of its citizens. An indefinite ban on Syrians was dropped. And the new order made clear that nationals of those six countries with valid visas or legal permanent residence (known as green cards) will not be restricted from traveling.

During Wednesday's hearings, government lawyers said those changes were designed to address the concerns raised by judges who blocked the first order. They said the government also removed a section of the original order that gave preference to persecuted religious minorities, which President Trump has said was designed to help Christians trying to immigrate from those majority Muslim countries.

But lawyers trying to block Trump's order argued that those tweaks don't change the underlying problem of the order — that it discriminates against Muslims. Those groups have taken to calling Trump's new order "Muslim Ban 2.0" and say it represents the illegal implementation of his campaign promise to institute a "total and complete shutdown of Muslims entering the United States."

The first hearing on Wednesday took place in Greenbelt, Md., before U.S. District Judge Theodore Chuang. A group of refugee resettlement organizations filed the suit, claiming the new order violates the religious freedom of refugees and violates other sections of the constitution and federal law.

Lee Gelernt, an ACLU attorney, said the judge pressed both sides on their claims: He asked government lawyers why he couldn't look at all of Trump's comments regarding Muslim immigration, and asked the refugee rights attorneys whether Trump is forbidden to limit immigration from anywhere in the world because of his campaign comments. Gelernt said the judge also asked about whether a nationwide ban or a more limited halt would be an appropriate remedy.

Chuang finished the hearing without issuing a ruling, saying he would decide soon but possibly not before the order went into effect.

The next hearing was held in Hawaii, where the state was joined by a Muslim imam to challenge the ban. They argue that the travel ban will hurt the state's economy by limiting tourism, business ties and educational opportunities, and also hurt individual Hawaii residents who cannot reconnect with their relatives in the six targeted countries.

U.S. District Judge Derrick Watson concluded the hearing without issuing a ruling, but said he would submit his order before the ban went into effect.

The final hearing was held in Washington state before the same judge who blocked Trump's first travel ban last month. U.S. District Judge James Robart also concluded his hearing without issuing a ruling.

Robart juggled several challenges. One came from the states of Washington, California, Maryland, Massachusetts, New York and Oregon, which claim the ban will hurt their economies and violate the rights of their citizens. The other challenge came from a group of U.S. citizens and legal permanent residents who said they will be prevented from reuniting with their family in the targeted countries.

Trump's first ban, signed Jan. 27, went into effect immediately, triggering chaos at airports around the world, as travelers overseas were blocked from boarding U.S.-bound flights and those in transit were detained at U.S. airports.

Robart halted the order, finding that it may have violated the rights of visa holders and legal permanent residents. That ruling was upheld by the 9th U.S. Circuit Court of Appeals in San Francisco.

Trump lashed out at Robart, calling him a "so-called judge," and at the 9th Circuit, saying their decision was politically motivated. The three-judge panel, which included two appointed by Democratic presidents and one by a Republican, issued a unanimous ruling.

Rather than continue fighting those rulings, the White House decided to revoke the initial order and replace it with the new, revised order, which no longer would ban those with permanent resident status or valid shorter-term visas.