The Supreme Court on Monday permitted a scaled-back version of President Trump’s ban on travelers from six mostly Muslim countries to take effect, deciding to hear the merits of the case in the fall but allowing Trump for now to claim a victory in the legal showdown.

The court’s unsigned order delivered a compromise neither side had asked for: It said the government may not bar those with a “bona fide” connection to the United States, such as having family members here, or a job or a place in an American university.

But the justices indicated that lower courts had gone too far in completely freezing Trump’s order banning new visas for citizens of six countries — Libya, Iran, Somalia, Sudan, Syria and Yemen — for 90 days and putting the refu­gee program on hold for 120 days.

“The Government’s interest in enforcing [the executive order], and the Executive’s authority to do so, are undoubtedly at their peak when there is no tie between the foreign national and the United States,” the court wrote.

Supreme Court, with ninth justice, now looks ahead to contentious fall term

Trump called the ruling “a clear victory for our national security.” In a statement, he said: “As president, I cannot allow people into our country who want to do us harm. I want people who can love the United States and all of its citizens, and who will be hardworking and productive.”

He added that he was “particularly gratified that the Supreme Court’s decision was 9-0.”

The president said last week that the order would go into effect 72 hours after being approved by the courts.

In the opinion, the court said it will hear arguments in the case — which raises fundamental questions about religious discrimination and the president’s broad powers to protect the nation — when it reconvenes in October.

In the meantime, the justices nudged the Trump administration to get on with what it said would be a temporary pause to review vetting procedures.

“We fully expect that the relief we grant today will permit the Executive to conclude its internal work and provide adequate notice to foreign governments” within 90 days, the court said.

That means that by the time the court takes up the case in the fall, circumstances could be quite different. Depending on the results of the review, Trump could push to extend the measure or even make it permanent.

A group of Muslim protesters gathers during a rally against the travel ban at San Diego International Airport on March 6. (Sandy Huffaker/AFP/Getty Images)

The court also told lawyers to address whether the justices’ consideration of the case in the fall might be moot, because administration officials will have had time to review vetting procedures.

Leon Fresco, who served as deputy assistant attorney general for the office of immigration litigation in President Barack Obama’s Justice Department, said the limited travel ban seems to affect two types of people who don’t necessarily have ties to the United States: those seeking U.S. visas as visitors and those trying to get visas through a government lottery meant for people from countries with historically low rates of immigration to the United States.

The State Department would not say how many visa seekers the ban would affect.

Anyone with a school acceptance letter, job offer or family member already here would probably be able to obtain a visa and travel as normal.

Interpretations of the court’s decision diverged widely among immigration lawyers and advocates.

Some, such as the American Civil Liberties Union, suggested that the decision would allow for “only the narrowest” implementation of the travel ban, affecting very few would-be travelers from the six countries.

But other groups, such as Amnesty International USA, warned of grave consequences, such as a renewal of “chaos” at airports and an enforcement of the ban that would “tear families apart.”

Justices Clarence Thomas, Samuel A. Alito Jr. and Neil M. Gorsuch would have let the ban take effect as the Trump administration crafted it, and Thomas wrote that the court had made an “implicit conclusion that the Government has made a strong showing that it is likely to succeed on the merits.”

The court’s revised order will “burden executive officials with the task of deciding — on peril of contempt — whether individuals from the six affected nations who wish to enter the United States have a sufficient connection to a person or entity in this country,” Thomas wrote.

Such a compromise, he wrote, will lead to a “flood of litigation” over what constitutes a “bona fide relationship.”

The travel ban has been a major point of contention between Trump and civil rights groups, which say it is motivated by unconstitutional discrimination against Muslims.

Trump contends that the ban is necessary to protect the nation while the administration decides whether tougher vetting procedures and other measures are needed. He has railed against federal judges who have blocked the move.

Because the executive order was stopped by lower courts, travelers from those countries have been entering the United States following normal visa procedures. Trump initially moved to implement the restrictions in January, in his first week in office.

His first executive order went into effect immediately and resulted in chaos at airports in the United States and abroad as travelers from the targeted nations were stranded or sent back to their countries.

Lawyers for challengers to the order rushed to federal courts, and the order was stayed within days. The U.S. Court of Appeals for the 9th Circuit eventually said the order could not be implemented, infuriating the president, who said he would take the case to the Supreme Court.

Instead, his administration regrouped and issued a second order in March. It added a section detailing national security concerns, removed Iraq from the list of countries affected, deleted a section that had targeted Syrian refugees and removed a provision that favored Christian immigrants.

Trump’s lawyers told courts that the new order was written to respond to the 9th Circuit’s concerns. But new lawsuits were immediately filed, and federal judges once again stopped the implementation.

A federal district judge in Maryland blocked the portion of the order affecting travelers from the six countries. A judge in Hawaii also froze that portion, as well as the part affecting refu­gee programs.

Appeals courts on both coasts upheld those decisions.

The U.S. Court of Appeals for the 4th Circuit in Richmond agreed with U.S. District Judge Theodore D. Chuang in Maryland, who sided with opponents in finding that the ban violates the Constitution by intentionally discriminating against Muslims. In a 10-to-3 decision, the appeals court noted Trump’s remarks before and after his election about a ban on Muslims and said the executive order “in context drips with religious intolerance, animus and discrimination.”

Meanwhile, a three-judge panel of the 9th Circuit said Trump had not adhered to federal law under which Congress gives the president broad power in immigration matters. They said that national security is not a “ ‘talismanic incantation’ that, once invoked, can support any and all exercise of executive power.”

In both appeals courts, a minority of conservative judges said their colleagues were making a mistake. Judges should consider only whether the executive orders were proper on their face, they said, without trying to decide whether the president had ulterior motives, and should defer to national security decisions made by the executive branch.

“The Supreme Court surely will shudder at the majority’s adoption of this new rule that has no limits or bounds,” wrote dissenting 4th Circuit Judge Paul V. Niemeyer.

Justice, Homeland Security and State department officials said they were still studying the decision to determine exactly who it affects and how it might be carried out.

The Supreme Court’s opinion seems unlikely to re-create the chaos that ensued after Trump issued his first travel ban, causing tens of thousands of visas to be revoked and some travelers to be detained and sent away from U.S. airports.

Trump already had rescinded and revised his first order so that it affected only the issuance of new visas, and the justices left intact an even more limited version. Advocates nonetheless said they would deploy people to watch for potential abuses.

“The court’s decision threatens damage to vulnerable people waiting to come to the U.S.: people with urgent medical conditions blocked, innocent people left adrift, all of whom have been extensively vetted,” said former British foreign secretary David Miliband, president of the International Rescue Committee.

That was in contrast to his thunderous Twitter offerings when courts previously disagreed with him. He wrote in one such post: “People, the lawyers and the courts can call it whatever they want, but I am calling it what we need and what it is, a TRAVEL BAN!”