The U.S. Supreme Court gave President Trump one of the biggest victories of his administration Tuesday , upholding his travel ban restricting travel to the U.S. for foreign nationals from seven countries.

The court ruled 5-4 along ideological lines in favor of the Trump administration in the case, which marked the first time one of Trump’s policies was reviewed by the justices. Trump quickly praised the decision in a tweet:



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



Chief Justice John Roberts delivered the opinion for the majority. Justice Anthony Kennedy, the crucial swing vote in the case, sided with the conservative justices.

[FULL OPINION: Supreme Court upholds Trump's travel ban]

Writing for the majority, Roberts said the president's travel executive order "is squarely within the scope of presidential authority" under federal immigration law .

"The proclamation is expressly premised on legitimate purposes: preventing entry of nationals who cannot be adequately vetted and inducing other nations to improve their practices," Roberts wrote. "The text says nothing about religion."

The chief justice said the government "set forth a sufficient national security justification" for the executive order to be upheld.

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

The case involved a challenge to the third iteration of Trump’s travel ban, which he signed in September 2017. The order placed restrictions on foreign nationals traveling to the U.S. from eight countries that Trump said were unable to determine whether its emigrants have terrorist backgrounds.

Six of those countries have Muslim-majority populations.

Two of the countries identified in the executive order, North Korea and Venezuela, were excluded from the court challenge, and a third, Chad, was removed from the list in April after the White House said it improved its information-sharing processes.

Challengers of Trump's third travel ban said the policy violated the Constitution and federal immigration law. They also argued the ban discriminates on the basis of religion, and cited Trump’s campaign statements and tweets showing anti-Muslim videos as evidence of that discrimination.

But the Trump administration argued the president was acting within his authority under federal immigration law in issuing his executive order in September. The proclamation, the administration said, was issued only after a government-wide review determined which countries had inadequate vetting policies for travelers looking to come to the U.S.

Roberts and the majority rejected the challengers' argument that the specific number of countries with Muslim-majority populations included in the executive order demonstrates Trump acted with animus toward Muslims, saying that alone "does not support an inference of religious hostility."

But the court’s liberal justices disagreed, and Justice Sonia Sotomayor slammed the Trump administration in a fiery dissent.

“It leaves undisturbed a policy first advertised open and unequivocally as a ‘total and complete shutdown of Muslims entering the United States’ because the policy now masquerades behind the façade of national-security concerns,” she wrote, citing Trump's December 2015 statement.

Sotomayor said this “repackaging does little to cleanse” the executive order “of the appearance of discrimination that the president’s words have created.”

Sotomayor also drew parallels between the travel ban case and the 1944 decision in Korematsu v. U.S., under which the Supreme Court upheld a presidential order requiring the internment of Japanese Americans during World War II.

The court denounced Korematsu on Tuesday, saying it was “gravely wrong the day it was decided." Sotomayor called the denunciation “laudable and long overdue.”

“But it does not make the majority’s decision here acceptable or right,” she said. “By blindly accepting the government’s misguided invitation to sanction a discriminatory policy motivated by animosity toward a disfavored group, all in the name of a superficial claim of national security, the court redeploys the same dangerous logic underlying Korematsu and merely replaces one ‘gravely wrong’ decision with another.”

Though Kennedy sided with the majority in upholding the travel ban, he issued a veiled warning to Trump in a concurring opinion that said while there are instances where the statements of government officials are "not subject to judiciary scrutiny or intervention," those officials are not "free to disregard the Constitution."

"Indeed, the very fact that an official may have broad discretion, discretion free from judiciary scrutiny, makes it all the more imperative for him or her to adhere to the Constitution and its meaning and its promise," Kennedy wrote.

The court's decision won praise from Attorney General Jeff Sessions, who called the ruling a "great victory for the safety and security of all Americans."

“Today’s decision is critical to ensuring the continued authority of President Trump — and all future presidents — to protect the American people," Sessions said. "We will continue to take and defend all lawful steps necessary to protect this great nation.”

But civil rights groups and Democratic lawmakers slammed the decision.

“This ruling will go down in history as one of the Supreme Court’s great failures," Omar Jadwat, director of the ACLU’s Immigrants’ Rights Project, said in a statement. "It repeats the mistakes of the Korematsu decision upholding Japanese-American imprisonment and swallows wholesale government lawyers’ flimsy national security excuse for the ban instead of taking seriously the president’s own explanation for his actions."

The justices heard arguments in the case in April on the term’s last day for arguments.