The Supreme Court on Tuesday upheld President Trump’s controversial travel ban affecting several mostly Muslim countries, offering a limited endorsement of the president’s executive authority on immigration in one of the hardest-fought battles of this term.

The 5-4 ruling marks the first major high court decision on a Trump administration policy. It upholds the selective travel restrictions, which critics called a discriminatory “Muslim ban” but the administration argued was needed for security reasons.

In a written statement, Trump called the ruling “a tremendous victory for the American People and the Constitution.” As critics continued to decry the policy as “xenophobic,” Trump described the court decision 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.”

CLICK TO READ THE DECISION

Chief Justice John Roberts, who authored the conservative majority opinion, wrote that the order was “squarely within the scope of presidential authority” under federal law.

“The sole prerequisite set forth in [federal law] is that the president find that the entry of the covered aliens would be detrimental to the interests of the United States. The president has undoubtedly fulfilled that requirement here,” he wrote.

Associate Justice Sonia Sotomayor was among the court’s four liberals that wrote a dissent.

“This repackaging does little to cleanse [the policy] of the appearance of discrimination that the president’s words have created,” she said. “Based on the evidence in the record, a reasonable observer would conclude that the proclamation was motivated by anti-Muslim animus.”

She and Justice Stephen Breyer took the unusual step of reading their dissents from the bench.

While the policy was upheld, the case was sent back to the lower courts, which were told to rely on the Supreme Court’s interpretation of executive authority.

It was the first significant legal test so far of Trump’s policies and power and could lead to a precedent-setting expansion on the limits of presidential authority, especially within the immigration context.

Federal appeals courts in Virginia and California in recent months had ruled against the administration. The San Francisco-based 9th Circuit Court last December concluded Trump’s proclamation, like the two previous executive orders, overstepped his powers to regulate the entry of immigrants and visitors.

But the justices had allowed the current restrictions to be enforced at the Justice Department’s request, at least until the case was fully litigated.

The Trump administration also seemed to enjoy a favorable reception before the court during arguments in April. Associate Justice Samuel Alito, during those April arguments, noted that of the 50 or so mostly Muslim majority countries, only five were on the current banned list.

The White House had framed the issue as a temporary move involving national security.

A coalition of groups in opposition called the order blatant religious discrimination, since the countries involved have mostly Muslim populations: Iran, Libya, Sudan, Syria and Yemen. Chad was recently removed from the list after the administration said that country had beefed up its information-sharing.

A major sticking point for the justices was navigating how much discretion the president really has over immigration. Courts have historically been deferential in this area, and recent presidents from Jimmy Carter to Ronald Reagan to Barack Obama have used it to deny entry to certain refugees and diplomats, including nations such as Iran, Cuba and North Korea.

A 1952 federal law — the Immigration and Nationality Act, passed in the midst of a Cold War fear over Communist influence — historically gives the chief executive broad authority.

It reads in part: “Whenever the president finds that the entry of any aliens or of any class of aliens into the United States would be detrimental to the interests of the United States, he may, may by proclamation, and for such period as he shall deem necessary, suspend the entry of all aliens or any class of aliens as immigrants or nonimmigrants, or impose on the entry of aliens any restrictions he may deem to be appropriate.”

The administration strongly denies this is a “Muslim ban,” but federal judges across the country cited statements by then-presidential candidate Trump and his advisers, including a December 2015 campaign press release calling for such restrictions and citing “hatred” by “large segments of the Muslim population.”

The high court’s majority downplayed Trump’s campaign statements as a major factor in its decision.

“The issue before us is not whether to denounce the statements,” wrote Roberts. “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. In doing so, we must consider not only the statements of a particular President, but also the authority of the Presidency itself.”

Sixteen state leaders led by Texas were among a number of coalitions backing the Trump administration. But Hawaii officials, who filed the appeal contesting all of the president’s orders, said the president’s policies violate the Constitution’s guarantee of religious freedom:

“Any reasonable observer who heard the president’s campaign promises, read his thinly justified orders banning overwhelmingly Muslim populations, and observed his administration’s persistent statements linking the two, would view the order and each of its precursors as the fulfillment of the president’s promise to prohibit Muslim immigration to the United States.”

Trump’s first executive order was issued just a week after he took office, and was aimed at seven countries. It triggered chaos and protests across the U.S., as some travelers were stopped from boarding international flights and others detained at airports for hours. Trump modified the order after a federal appeals court refused to allow the ban to be enforced.

“This is not about religion — this is about terror and keeping our country safe,” the president said on Jan. 29, 2017.

The next version, unveiled weeks later, 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 valid visas. It also got rid of language that would give priority to religious minorities. Critics said the changes did not erase the legal problems with the ban.

When that second temporary travel ban expired in Sept. 24, it was replaced with Proclamation 9645 — what the administration said was a country-by-country assessment of security and cooperation with the U.S.

Source:  Fox News/The Associated Press contributed to this report.