WASHINGTON (AP) -- A sharply divided Supreme Court upheld President Donald Trump's ban on travel from several mostly Muslim countries Tuesday, the conservative majority taking his side in a major ruling supporting his presidential power. A dissenting liberal justice said the court was making a historic mistake by refusing to recognize the ban discriminates against Muslims.
The 5-4 decision was a big victory for Trump in the court's first substantive ruling on one of his administration's policies. It also was the latest demonstration of a newly invigorated conservative majority and a bitter defeat for the court's liberals.
The ruling came on an issue that has been central for Trump, from his campaign outbursts against "radical Islamic terrorism" through his presidency. He tweeted a quick reaction -- "Wow!" -- and then celebrated at greater length before TV cameras.
Chief Justice John Roberts wrote the majority opinion for the five conservative justices, including Trump nominee Neil Gorsuch, who got his seat only after Republicans blocked President Barack Obama's nominee for the last 10 months of Obama's term.
Roberts wrote that the travel ban was well within U.S. presidents' considerable authority over immigration and responsibility for keeping the nation safe. He rejected the challengers' claim of anti-Muslim bias that rested in large part on Trump's own tweets and statements over the past three years.
But Roberts was careful not to endorse either Trump's statements about immigration in general or Muslims in particular, including his campaign call for "a complete and total shutdown of Muslims entering the United States."
"We express no view on the soundness of the policy," Roberts wrote.
The travel ban has been fully in place since December, when the justices put the brakes on lower court rulings that had ruled the policy out of bounds and blocked part of it from being enforced. It applies even to people with close relatives in the United States and other strong connections to the country.
In a dissent she summarized aloud in court, Justice Sonia Sotomayor said, "History will not look kindly on the court's misguided decision today, nor should it." Justices Stephen Breyer, Ruth Bader Ginsburg and Elena Kagan also dissented.
Sotomayor wrote that based on the evidence in the case "a reasonable observer would conclude that the Proclamation was motivated by anti-Muslim animus." She said her colleagues in the majority arrived at the opposite result by "ignoring the facts, misconstruing our legal precedent and turning a blind eye to the pain and suffering the Proclamation inflicts upon countless families and individuals, many of whom are United States citizens."
She likened the case to the discredited Korematsu V. U.S. decision that upheld the detention of Japanese-Americans during World War II. Roberts responded in his opinion that "Korematsu has nothing to do with this case" and "was gravely wrong the day it was decided."
The travel ban was among the court's biggest cases this term and the latest in a string of 5-4 decisions in which the conservative side of the court, bolstered by the addition of Gorsuch last year, prevailed. He was chosen by Trump after Republicans in the Senate refused to grant a hearing to federal appeals Judge Merrick Garland who was nominated by Obama in March 2016.
Soon after the ruling, the campaign of Senate Majority Leader Mitch McConnell of Kentucky, who orchestrated the strategy to keep the high court seat away from Obama, tweeted a photo of McConnell and Gorsuch.
The Trump policy applies to travelers from five countries with overwhelmingly Muslim populations -- Iran, Libya, Somalia, Syria and Yemen. It also affects two non-Muslim countries, blocking travelers from North Korea and some Venezuelan government officials and their families. A sixth majority Muslim country, Chad, was removed from the list in April after improving "its identity-management and information sharing practices," Trump said in a proclamation.
The administration had pointed to the Chad decision to show that the restrictions were premised only on national security concerns.
The challengers, though, argued that the court could not just ignore all that had happened, beginning with Trump's campaign tweets to prevent the entry of Muslims into the United States.
Trump had proposed a broad, all-encompassing Muslim ban during the presidential campaign in 2015, drawing swift rebukes from Republicans as well as Democrats. And within a week of taking office, the first travel ban was announced with little notice, sparking chaos at airports and protests across the nation.
While the ban has changed shape since then, it has remained a key part of Trump's "America First" vision, with the president contending that the restriction, taken in tandem with his promised wall at the southern border, would make the Unites States safer from potentially hostile foreigners.
On Tuesday, he hailed the ruling as "a moment of profound vindication" following "months of hysterical commentary from the media and Democratic politicians who refuse to do what it takes to secure our border and our country."
Strongly disagreeing, Democratic Rep. Keith Ellison of Minnesota said, "This decision will someday serve as a marker of shame." Ellison, the first Muslim elected to Congress, and Sen. Mazie Hirono of Hawaii, who was born in Japan, both compared the ban and the ruling to the internment of Japanese-Americans during World War II.
Critics of Trump's ban had urged the justices to affirm the decisions in lower courts that generally concluded that the changes made to the travel policy did not erase the ban's legal problems. Trump had also imposed a temporary ban on refugees along with earlier versions of the travel ban, but he did not reimpose a refugee ban when the last one expired in the fall.
The current travel ban dates from last September and it followed what the administration has called a thorough review by several federal agencies, although no such review has been shared with courts or the public.
Federal trial judges in Hawaii and Maryland had blocked the travel ban from taking effect, finding that the new version looked too much like its predecessors. Those rulings that were largely upheld by federal appeals courts in Richmond, Virginia, and San Francisco.
But the Supreme Court came to a different conclusion Tuesday. The policy has "a legitimate grounding in national security concerns," and it has several moderating features, including a waiver program that would allow some people from the affected countries to enter the U.S., Roberts said. The administration has said that 809 people have received waivers since the ban took full effect in December.
Roberts wrote that presidents have frequently used their power to talk to the nation "to espouse the principles of religious freedom and tolerance on which this Nation was founded." But he added that presidents and the country have not always lived up "to those inspiring words."
The challengers to the ban asserted that Trump's statements crossed a constitutional line, Roberts said.
"But the issue before us is not whether to denounce the statements. It is instead the significance of those statements in reviewing a Presidential directive, neutral on its face, addressing a matter within the core of executive responsibility," he said
Associated Press writers Ashraf Khalil and Jonathan Lemire contributed to this report.