WASHINGTON — The U.S. Supreme Court, in a 5-4 ruling, upheld President Donald Trump's restriction on travel to the United States from a handful of Muslim countries on Tuesday, giving the White House its first high court victory on the merits of a presidential initiative.

Chief Justice John Roberts, writing for the majority, made it clear that the court viewed the ability to regulate immigration as squarely within a president's powers and he rejected critics' claims of anti-Muslim bias.

"We express no view on the soundness of the policy," Roberts wrote.

After a series of federal court rulings invalidated or scaled back earlier versions of the travel ban, the decision is a big win for the administration and ends 15 months of legal battles over a key part of Trump's immigration policy, which opponents attacked as a dressed-up form of the Muslim ban that Trump promised during his 2016 campaign.

Trump tweeted his happiness with the opinion shortly after it was released.

SUPREME COURT UPHOLDS TRUMP TRAVEL BAN. Wow! — Donald J. Trump (@realDonaldTrump) June 26, 2018

Justice Sonia Sotomayor wrote in her 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 on the court 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."

Later, in a statement, Trump called the opinion "a moment of profound vindication."

"The Supreme Court has upheld the clear authority of the president to defend the national security of the United States," Trump said. "In this era of worldwide terrorism and extremist movements bent on harming innocent civilians, we must properly vet those coming into our country. This ruling is also 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."

At the White House, the president told reporters the ruling was a "tremendous victory for the American people. ... We just need to know who's coming here."

In the majority opinion, Roberts, joined by the court's other four conservatives, said Trump's order "is expressly premised on legitimate purposes: preventing entry of nationals who cannot be adequately vetted and inducing other nations to improve their practices."

"The text says nothing about religion," Roberts wrote. "Plaintiffs and the dissent nonetheless emphasize that five of the seven nations currently included in the (ban) have Muslim-majority populations. Yet that fact alone does not support an inference of religious hostility, given that the policy covers just 8 percent of the world's Muslim population and is limited to countries that were previously designated by Congress or prior administrations as posing national security risks."

Imposed last September by presidential proclamation, the latest version maintains limits on granting visas to travelers from five of the seven countries covered by the original executive order on travel — Iran, Libya, Somalia, Syria and Yemen. It lifted restrictions on visitors from Sudan, and it adds new limits on North Korea and Venezuela.

Chad was part of the proclamation but was taken off the list in April after the White House said it met enhanced visa security requirements. Iraq was listed in the original travel ban imposed last year but was removed in the second version.

The state of Hawaii, three of its residents and a Muslim-American group challenged the new restrictions, and a federal judge blocked enforcement. But the Supreme Court lifted the stay last December, and the government has been carrying it out in full since.

The American Civil Liberties Union said Tuesday that it's "not the first time the Court has been wrong."

BREAKING: SCOTUS has upheld Trump’s Muslim ban. This is not the first time the Court has been wrong, or has allowed official racism and xenophobia to continue rather than standing up to it.



History has its eyes on us — and will judge today’s decision harshly. #NoMuslimBanEver — ACLU (@ACLU) June 26, 2018

Neal Katyal, who represented challengers to the travel ban, saying that the policy is unwise and un-American.

"We continue to believe, as do four dissenting justices, that the travel ban is unconstitutional, unprecedented, unnecessary and un-American," he said in a statement. "We decided long ago that America doesn't exclude people based on nationality or religion alone. Today, that principle has been challenged. But the final chapter has not yet been written, and the president would be mistaken to interpret today's decision as a greenlight to continue his unwise and un-American policies. ... The travel ban is atrocious policy, and makes us less safe and undermines our American ideals."

The Trump administration argued that the latest version of the travel ban is different, because it was imposed only after the administration surveyed more than 200 countries for their effectiveness in providing information about the backgrounds of visa applicants and success in fighting terrorism.

The Justice Department said the Constitution and federal laws give the president broad authority to suspend or restrict entry into the country when it is deemed to be in the nation's interest. While immigration law doesn't require the president to spell out detailed findings before invoking the authority, the government said, the September proclamation was more detailed than any previous order limiting travel.

But Hawaii and the other challengers said federal law gives the president the power to ban only foreign nationals who share some characteristics making them harmful to the U.S.

The travel ban was flawed, they said, because it restricted entry by 150 million people who share nothing in common but nationality. They also said the proclamation was based on religious animus, citing frequent promises from Trump, as a candidate and as president, to impose a Muslim ban.

The first executive order on travel, announced in February 2017, caused chaos at major airports when border officials refused to admit travelers who were in flight when the rules went into effect. It was quickly blocked by the courts.

Enforcement of a second travel ban, issued about a month later, was also stopped by lower court judges. The Supreme Court then allowed it to be enforced except for visa applicants with family or other close U.S. connections, but the revised version expired before it was to be the subject of full-blown Supreme Court review last fall.