A federal judge in Hawaii issued a nationwide order Wednesday evening blocking President Trump’s ban on travel from parts of the Muslim world, dealing a stinging blow to the White House and signaling that Mr. Trump will have to account in court for his heated rhetoric about Islam.

A second federal judge in Maryland ruled against Mr. Trump overnight, with a separate order forbidding the core provision of the travel ban from going into effect.

The rulings were a second major setback for Mr. Trump in his pursuit of a policy that he has trumpeted as critical for national security. His first attempt to sharply limit travel from a handful of predominantly Muslim countries ended in a courtroom fiasco last month, when a federal court in Seattle halted it.

Mr. Trump issued a new and narrower travel ban, affecting six countries, on March 6, trying to satisfy the courts by removing some of the most contentious elements of the original version.

Image

Attorney General Doug Chin of Hawaii, who filed the lawsuit, in Honolulu on Wednesday.CreditHugh Gentry/Reuters

But in a pointed decision that repeatedly invoked Mr. Trump’s public comments, Judge Derrick K. Watson, of Federal District Court in Honolulu, wrote that a “reasonable, objective observer” would view even the new order as “issued with a purpose to disfavor a particular religion, in spite of its stated, religiously neutral purpose.”

In Maryland, Judge Theodore D. Chuang echoed that conclusion hours later, ruling in a case brought by nonprofit groups that work with refugees and immigrants, that the likely purpose of the executive order was “the effectuation of the proposed Muslim ban” that Mr. Trump pledged to enact as a presidential candidate.

Mr. Trump lashed out at Judge Watson during a campaign-style rally in Nashville late on Wednesday. Raising his voice to a hoarse shout, Mr. Trump accused the judge of ruling “for political reasons” and criticized the United States Court of Appeals for the Ninth Circuit, which upheld the earlier decision against his administration and will hear any appeal to the Hawaii ruling.

“This ruling makes us look weak, which by the way we no longer are, believe me,” Mr. Trump said, to mounting cheers from a loyal crowd.

Mr. Trump even said he might reissue the initial version of the order, rather than the one blocked on Wednesday, which he described as “a watered-down version of the first one.”

Image

Hakim Ouansafi, the chairman of the Muslim Association of Hawaii, in Honolulu on Wednesday.CreditKent Nishimura for The New York Times

After he signed the revised ban, Democratic attorneys general and nonprofit groups that work with immigrants and refugees raced back into court, claiming that Mr. Trump’s updated decree was still a thinly veiled version of the ban on Muslim migration that he proposed last year.

Judge Watson, who was appointed by President Barack Obama, ruled that the State of Hawaii and an individual plaintiff, Ismail Elshikh, the imam of the Muslim Association of Hawaii, had reasonable grounds to challenge the order as religious discrimination. And he concluded that allowing the travel restrictions to go into effect at midnight, as scheduled, could have caused them irreparable harm.

Judge Watson flatly rejected the government’s argument that a court would have to investigate Mr. Trump’s “veiled psyche” to deduce religious animus. He quoted extensively from the remarks by Mr. Trump that were cited in the lawsuit brought by Hawaii’s attorney general, Doug Chin.

“For instance, there is nothing ‘veiled’ about this press release,” Judge Watson wrote, quoting a Trump campaign document titled “Donald J. Trump is calling for a total and complete shutdown of Muslims entering the United States.”

Judge Watson singled out Mr. Elshikh, an American citizen whose Syrian mother-in-law had been pursuing a visa to enter the United States, as having an especially strong claim that the travel regulations would harm him on the basis of his religion.

“This is a great day for democracy, religious and human rights,” Mr. Elshikh, who was out of the country, said in a message relayed through Hakim Ouansafi, the chairman of the Muslim Association of Hawaii. “I am very pleased that the processing of my mother-in-law’s paperwork will not stop now but more importantly that this Muslim ban will not separate families and loved ones just because they happen to be from the six countries.”

Mr. Elshikh, who is Egyptian and previously worked in Michigan, was recruited to the Hawaii mosque more than a decade ago, Mr. Ouansafi said. And when the association began recruiting someone to serve as a plaintiff, the imam, who became a citizen last year, agreed to do so without reservation, Mr. Ouansafi said.

After he became the face of the lawsuit, he received several threats from the mainland, Mr. Ouansafi said. “If we lived in any other state, I would not have asked him to come forward,” he said.

In the Maryland case, Judge Chuang, who was also appointed by Mr. Obama, declined to block the entire executive order from going into effect, but ruled that the most important section — banning travel from half a dozen countries — could not be enforced. His decision cited Mr. Trump’s public comments to conclude that there were “strong indications that the national security purpose is not the primary purpose for the travel ban,” and that Mr. Trump may have intended to violate the constitutional prohibition on religious preferences.

In addition to the Hawaii and Maryland suits, a federal judge in Washington State heard arguments Wednesday in cases challenging the constitutionality of Mr. Trump’s order, including one brought by a coalition of Democratic attorneys general, and another by nonprofit groups.

Administration lawyers have argued that the president was merely exercising his national security powers. In the scramble to defend the executive order, a single lawyer in the United States solicitor general’s office, Jeffrey Wall, argued first to a Maryland court and then, by phone, to Judge Watson in Honolulu that no element of the order, as written, could be construed as a religious test for travelers.

Mr. Wall said the order was based on concerns raised by the Obama administration in its move toward stricter screening of travelers from the six countries affected.

“What the order does is a step beyond what the previous administration did, but it’s on the same basis,” Mr. Wall said in the Maryland hearing.

After Mr. Trump’s speech in Nashville, the Justice Department released a more muted statement disputing the Hawaii decision, calling it “flawed both in reasoning and scope.” Sarah Isgur Flores, a spokeswoman for the department, said it would continue to defend the legality of the presidential order.

Refugee organizations and civil rights groups greeted the Hawaii ruling with expressions of triumph and relief. Marielena Hincapié, executive director of the National Immigration Law Center, one of the groups that sued Mr. Trump in Maryland, hailed Judge Watson’s ruling as “a strong and unequivocal rejection of the politics of hate.”

At the same time, advocates for refugees and immigrants acknowledged that significant uncertainty would hang over some of their more practical decisions, as a longer legal process plays out around Mr. Trump’s order.

“It’s a preliminary decision, but it recognizes that there continue to be problems with the constitutionality of this revised order, particularly with discriminatory intent toward Muslims,” said Betsy Fisher, policy director at the International Refugee Assistance Project at the Urban Justice Center.

The original ban, released on Jan. 27, unleashed scenes of chaos at American airports and spurred mass protests. Issued abruptly on a Friday afternoon, it temporarily barred travel from seven majority-Muslim nations, making no explicit distinction between citizens of those countries who already had green cards or visas and those who did not. It also suggested that Christian refugees from those countries would be given preference in the future.

After the federal court in Seattle issued a broad injunction against the policy, Mr. Trump removed major provisions and reissued the order. The new version exempted key groups, like green card and visa holders, and dropped the section that would have given Christians special treatment.

Mr. Trump also removed Iraq from the list of countries covered by the ban after the Pentagon expressed worry that it would damage the United States’ relationship with the Iraqi government in the fight against the Islamic State.

Yet those concessions did not placate critics of the ban, who said it would still function as an unconstitutional religious test, albeit one affecting fewer people — an argument Judge Watson concurred with in his ruling.

The lawsuits have also claimed that the order disrupts the operations of companies, charities, public universities and hospitals that have deep relationships overseas. In the Hawaii case, nearly five dozen technology companies, including Airbnb, Dropbox, Lyft and TripAdvisor, joined in a brief objecting to the travel ban.

The second, now-halted executive order preserved major components of the original. It would have ended, with few exceptions, the granting of new visas and green cards to people from six majority-Muslim countries — Iran, Libya, Somalia, Sudan, Syria and Yemen — for at least 90 days. It would have also stopped all refugees from entering for 120 days and limited refugee admissions to 50,000 people in the current fiscal year.

Mr. Obama had set in motion plans to admit more than twice that number.

Mr. Trump has said the pause is needed to re-evaluate screening procedures for immigrants from the six countries. “Each of these countries is a state sponsor of terrorism, has been significantly compromised by terrorist organizations, or contains active conflict zones,” he wrote in the order.

The two court orders were not a final ruling on the constitutionality of Mr. Trump’s ban, and the administration has expressed confidence that courts will ultimately affirm Mr. Trump’s power to issue the restrictions.

But the legal debate is likely to be a protracted and unusually personal fight for the administration, touching Mr. Trump and a number of his key aides directly and raising the prospect that their public comments and private communications will be scrutinized.

The lawsuits against the ban have extensively cited Mr. Trump’s comments during the presidential campaign. Attorney General Bob Ferguson of Washington, who successfully challenged Mr. Trump’s first order, has indicated that in an extended legal fight, he could seek depositions from administration officials and request documents that would expose the full process by which Trump aides crafted the ban.

As a candidate, Mr. Trump first proposed to bar all Muslims from entering the United States, and then offered an alternative plan to ban travel from a number of Muslim countries, which he described as a politically acceptable way of achieving the same goal.

The lawsuits also cited Rudolph W. Giuliani, the former New York City mayor who advises Mr. Trump. Mr. Giuliani said he had been asked to help craft a Muslim ban that would pass legal muster.

And they highlighted comments by Stephen Miller, an adviser to the president, who cast the changes to Mr. Trump’s first travel ban as mere technical adjustments aimed at ushering the same policy past the review of a court.