In saying they would take the case, the justices partly endorsed the administration’s view that the president has vast authority to control who crosses the border. They said the president’s powers to limit immigration “are undoubtedly at their peak when there is no tie between the foreign national and the United States.”

But the opinion also signaled that some of the justices might believe that Mr. Trump exceeded even that broad authority when he twice sought to impose a blanket ban on entry to the United States from certain predominantly Muslim countries. With the limits imposed on Monday by the court, the travel ban will be far narrower than the one he proposed in his first week in office and a later, revised version.

For Mr. Trump, the opinion was a rare legal victory after months in which the lower courts repeatedly chastised him for imposing a de facto ban on Muslims’ entering the country. In May, the United States Court of Appeals for the Fourth Circuit, in Richmond, Va., said the president’s revised order “drips with religious intolerance, animus and discrimination.”

In a statement, officials at the Department of Homeland Security said the court opinion would allow the department “to largely implement the President’s executive order.” Mr. Trump used similar language in his statement, saying his travel ban would now “become largely effective.”

Critics of the ban disputed those assessments. Cecillia Wang, the deputy legal director for the American Civil Liberties Union, said the opinion meant that the ban would not apply to many people while the court case proceeds.

“Clearly, the White House press statement today is based on alternative facts,” Ms. Wang said.

The court’s decision could lead to months of administrative and legal wrangling as consular officials try to determine which people are allowed to seek entry into the United States and which are barred by the opinion.