(Adds quotes from justice, details on ruling)
WASHINGTON, June 26 (Reuters) - The U.S. Supreme Court on Monday handed a victory to President Donald Trump by allowing his temporary ban on travelers from six Muslim-majority countries and all refugees to go into effect for people with no strong ties to the United States while agreeing to decide this fall the legality of the order.
The case represents a major test of presidential powers. The justices, in their unsigned decision, granted parts of the Trump administration's emergency request to put the order into effect immediately while the legal battle continues.
The court, which narrowed the scope of lower court rulings that had completely blocked his March 6 executive order, said it would hear arguments in October on the lawfulness of one of Trump's signature policies in his first months as president
The March 6 order called for a 90-day ban on travelers from Libya, Iran, Somalia, Sudan, Syria and Yemen and a 120-day ban on all refugees to enable the government to implement stronger vetting procedures. It was blocked by federal judges before going into effect on March 16 as planned.
Both bans are now due to partly go into effect in 72 hours, based on a memorandum issued by the Trump administration on June 14.
Even before the Supreme Court action the ban applied only to new visa applicants, not people who already have visas or are U.S. permanent residents, known as green card holders. The executive order also made waivers available for a foreign national seeking to enter the United States to resume work or study, visit a spouse, child or parent who is a U.S. citizen, or for "significant business or professional obligations." Refugees "in transit" and already approved would have been able to travel to the United States under the executive order.
The case is Trump's first major challenge at the Supreme Court, where he restored a 5-4 conservative majority with the appointment of Neil Gorsuch, who joined the bench in April.
There are five Republican appointees on the court and four Democratic appointees.
Three of the court's conservatives said they would have granted Trump's request to reinstate the order in full, including Gorsuch. Justice Clarence Thomas warned that requiring officials to differentiate between foreigners who have connection to the U.S. and those who do not will prove unworkable.
"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," Thomas wrote.
The justices said that the travel ban will go into effect "with respect to foreign nationals who lack any bona fide relationship with a person or entity in the United States." That indicates that people from the six countries and refugees who have family, business or other ties would not be barred from entry. But those seeking visas to enter the United States with no such ties could be barred.
The decision endorsed the Trump administration's contention that the president deserves greater deference from the courts on national security matters.
The court said that Trump's executive order distinguished between foreigners who have "some connection to this country" and those who do not, and said the government had committed to review cases for those with some connection to the United States on a case-by-case basis.
The Supreme Court left the lower-court injunctions against the ban in place, but only with respect to the challengers to the ban themselves and others in similar circumstances, meaning they involve people in the United States who have relationships with foreign nationals abroad and whose rights might be affected if those foreigners were excluded from entry.
But the court said the injunctions were too broad to also include barring enforcement of the ban against foreigners who have no connection to the United States at all. "Denying entry to such a foreign national does not burden any American party by reason of that party's relationship with the foreign national," the court said.
The court handled the refugee ban in a similar way, allowing the government to exclude from the United States refugee claimants who do not have any "bona fide relationship" with an American individual or entity.
Thomas said this will lead to a flood of litigation as courts try to figure out who has a bona fide relationship with the United States.
Trump issued the order amid rising international concern about attacks carried out by Islamist militants like those in Paris, London, Brussels, Berlin and other cities. But critics have called the order a mean-spirited, intolerant and un-American "Muslim ban."
The state of Hawaii and a group of plaintiffs in Maryland represented by the American Civil Liberties Union argued that the order violated federal immigration law and the Constitution's First Amendment prohibition on the government favoring or disfavoring any particular religion. Regional federal appeals courts in Virginia and California both upheld district judge injunctions blocking the order.
Trump signed the order as a replacement for a Jan. 27 order issued a week after he became president that also was blocked by federal courts. The revised order was intended to overcome the legal issues posed by the original ban, which also included Iraq among the nations targeted and a full ban on refugees from Syria. The revised order also jettisoned language that gave preferential status to persecuted religious minorities, which critics said could be taken as favoring Christians and other religious groups over Muslims.
Trump has called the March order a "watered down, politically correct" version of the January one. But the order still embodied his "America First" nationalist message and reflected his views of the dangers posed to the United States by certain immigrants and visitors.
The administration has said the travel ban is needed to allow time to implement stronger vetting measures, although it has already rolled out some new requirements not blocked by courts, including additional questions for visa applicants. (Reporting by Lawrence Hurley. Additional reporting by Andrew Chung; Editing by Will Dunham)