The original measure, issued by executive order in January and nearly immediately blocked by the courts, also included Iraq on the list of targeted countries and had imposed an indefinite ban on Syrian refugees.
The 90-day ban is necessary to allow an internal review of screening procedures for visa applicants from the countries, the administration says.
Opponents say the ban is unlawful, based on visitors' Muslim religion.
The State Department vowed in a statement to keep travelers and travel industry partners informed as it implements the order, and to keep the US Refugee Admissions Program "apprised of changes as they take effect".
That means the temporary ban will go into effect Thursday morning. Justice Clarence Thomas said the government's interest in ensuring national security should outweigh any hardship to people denied entry into the U.S.
Shortly after the court issued its opinion the American Civil Liberties Union (ACLU) said on Twitter it would "head back into court to fight the fundamentally unconstitutional Muslim ban this October". "Today's compromise 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".
To be clear, the Supreme Court did not say the ban is legal as applied to those individuals.More news: Volvo And Autoliv Partner With Nvidia For Self-Driving Cars
The order was however blocked by federal judges before going into effect on March 16 as planned. Both courts reached their conclusions in March in part by examining Trump's record as a candidate, which included his 2015 statement "calling for a total and complete shutdown of Muslims entering the United States".
HIAS - formerly known as the Hebrew Immigrant Aid Society - is among the plaintiffs suing Trump in one of the cases the Supreme Court agreed to take on. A number of high-profile officials from the sphere of national security have claimed that the travel ban will not make the country any safer, and could in fact have the opposite effect. They noted that most people coming to study, work or visit family members in the US already have sufficient relationships with others already in the country.
Margo Schlanger, a professor of law at the University of MI, who also headed the civil rights and civil liberties division at the Department of Homeland Security under Barack Obama from 2010-11, said the supreme court had actually paved the way for the bulk of travelers affected by the ban to come into the US. But under the immigration system, most people traveling to the United States do have those ties.
"As for entities, the relationship must be formal, documented, and formed in the ordinary course, rather than for the objective of evading the executive order".
That's no minor exception, according to immigrant groups, who say relatively few people come to the US from the affected countries without such close ties.
TOTENBERG: Indeed the court has added a question for the October argument, one not addressed by the lower courts - whether the case is moot.
Meanwhile, a three-judge panel of the 9th Circuit said Trump had not adhered to federal law in which Congress gives the president broad power in immigration matters. Trump's order embodied his "America First" message and reflected his views of the dangers posed to the U.S. by certain immigrants.