“The Immigration and Nationality Act ... gives the President broad powers to control the entry of aliens, and to take actions to protect the American public. But immigration, even for the President, is not a one-person show,” said the court in a unanimous, unsigned ruling.

“The President’s authority is subject to certain statutory and constitutional restraints. We conclude that the President, in issuing the Executive Order, exceeded the scope of the authority delegated to him by Congress,” the court added.

Defending itself from lawsuits filed across the country, the Department of Justice has maintained that the travel restrictions are “facially legitimate” and were issued in good faith, while denying that they were meant to disfavor a particular religious group. Instead, the administration has argued the travel ban is a lawful exercise of the president’s authority, given to him by Congress, to exclude noncitizens from the country.

Relying on this latter argument, the 9th Circuit took a narrow path and ruled only on Trump’s statutory power to issue the executive order. It declined to delve into the larger constitutional issues — such as whether the restrictions violate the Constitution’s prohibition on treating certain religions more or less favorably than others.

Under immigration law, the president may bar foreign nationals that, in his judgment, are “detrimental to the interests of the United States.” But the court said that none of the reasons that Trump and his team offered to justify banning nationals from Iran, Libya, Somalia, Sudan, Syria and Yemen satisfied the law’s requirement.

“The Order makes no finding that nationality alone renders entry of this broad class of individuals a heightened security risk to the United States,” the 9th Circuit said.

“The Order does not tie these nationals in any way to terrorist organizations within the six designated countries. It does not identify these nationals as contributors to active conflict or as those responsible for insecure country conditions. It does not provide any link between an individual’s nationality and their propensity to commit terrorism or their inherent dangerousness,” the court added.

”Indeed, the President recently confirmed his assessment that it is the countries that are inherently dangerous, rather than the 180 million individual nationals of those countries who are barred from entry under the President’s travel ban,” the court said.

On one small point, the three judges did side with Trump. The 9th Circuit reversed the part of the Hawaii ruling from March that prevented the government from tightening internal vetting processes for those seeking entry into the country. The court noted that permitting that review process to move forward would not harm those affected by the executive order.

Asked about the ruling during a White House briefing Monday, press secretary Sean Spicer said the administration is reviewing the ruling but expressed confidence the Supreme Court will ultimately vindicate the administration.

“I think we can all attest that these are very dangerous times and we need every available tool at our disposal to prevent terrorists from entering the United States and committing acts of bloodshed and violence,” Spicer said.

Trump finally responded to the ruling on Tuesday:

Well, as predicted, the 9th Circuit did it again - Ruled against the TRAVEL BAN at such a dangerous time in the history of our country. S.C.

The administration, for its part, has already asked the Supreme Court to reinstate the travel ban by dissolving both the Hawaii and Maryland rulings, which apply nationwide and effectively prevent the administration from enforcing both the travel restrictions and reducing the cap on refugees.

Just as the 9th Circuit ruled on Monday, lawyers for the state of Hawaii and the refugee organization in the Maryland case filed briefs with the high court urging the justices to stay out of the dispute altogether — in part because it’s been a long time since Trump signed the order in March and there’s no urgency in reviving the travel ban now.

“Respondents have repeatedly explained, both at the District Court and at the Ninth Circuit, that the Executive is free to engage in any manner of study, review, upgrade or revision of its existing vetting procedures,” Hawaii said in a brief filed Monday at the Supreme Court. “The only thing the injunction prevents it from doing is engaging in those activities as an excuse for, or in order to perpetuate, the President’s unconstitutional travel and refugee bans.”

This story has been updated with details from the ruling and with response from the president.