WASHINGTON (AP) -- The Supreme Court on Tuesday upheld President Donald Trump's ban on travel from several mostly Muslim countries, rejecting a challenge that it discriminated against Muslims or exceeded his authority.
The 5-4 decision Tuesday is the court's first substantive ruling on a Trump administration policy, and the president quickly tweeted his reaction: "Wow!"
Chief Justice John Roberts wrote the majority opinion, joined by his four conservative colleagues.
Roberts wrote that presidents have substantial power to regulate immigration. He also rejected the challengers' claim of anti-Muslim bias.
But he was careful not to endorse either Trump's provocative statements about immigration in general and Muslims in particular.
"We express no view on the soundness of the policy," Roberts wrote.
The travel ban has been fully in place since the court declined to block it in December. The justices allowed the policy to take full effect even as the court fight continued and lower courts had ruled it out of bounds.
Justice Sonia Sotomayor wrote in a dissent 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 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."
Justices Stephen Breyer, Ruth Bader Ginsburg and Elena Kagan also dissented.
The 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 are premised only on national security concerns.
The challengers, though, argued that the court could just ignore all that has happened, beginning with Trump's campaign tweets to prevent the entry of Muslims into the United States. Just a week after he took office in January 2017, Trump announced his first travel ban aimed at seven countries.
That triggered chaos and protests across the U.S. as travelers were stopped from boarding international flights and detained at airports for hours. Trump tweaked the order after the 9th U.S. Circuit Court of Appeals in San Francisco refused to reinstate the ban.
The next version, unveiled in March 2017, dropped Iraq from the list of covered countries and made it clear the 90-day ban covering Iran, Libya, Somalia, Sudan, Syria and Yemen didn't apply to those travelers who already had visas. It also eliminated language that would give priority to religious minorities. Critics said the changes didn't erase the ban's legal problems.
The current version dates from September and it followed what the administration has called a thorough review by several federal agencies, although it has not shared the review 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.
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."