The ruling was 5-4 along partisan lines, with Chief Justice John Roberts writing for the conservative majority.

The ruling sends a strong message that Trump has broad powers under immigration law to act to protect national security and that statements made during a campaign may not be legally determinative of the President's intent.

"The Proclamation is squarely within the scope of Presidential authority," Roberts wrote.

Trump immediately reacted on Twitter:

SUPREME COURT UPHOLDS TRUMP TRAVEL BAN. Wow!

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

The President then called the ruling "a tremendous victory for the American People and the Constitution" and said he felt vindicated.

"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," Trump said.

This is the third version of the travel ban. It was issued in September -- after previous bans had ricocheted through the courts -- and restricts entry from seven countries to varying degrees: Iran, North Korea, Syria, Libya, Yemen, Somalia and Venezuela. Chad was originally on the list but it was recently removed after having met baseline security requirements.

Challengers, including the state of Hawaii, argued that the travel ban exceeded the President's authority under immigration law as well as the Constitution. They also used Trump's statements during the campaign, when he called for a ban on travel from all Muslim-majority countries, but Roberts dismissed those concerns.

"Plaintiffs argue that this President's words strike at fundamental standards of respect and tolerance, in violation of our constitutional tradition," Roberts wrote. "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. In doing so, we must consider not only the statements of a particular President, but also the authority of the Presidency itself."

Stephen Vladeck, CNN's Supreme Court analyst and a law professor at the University of Texas School of Law, called the ruling a "big win" for the White House.

"The Supreme Court has reaffirmed the President's sweeping statutory authority when it comes to deciding who may and who may not travel to the United States, authority that both President Trump and future presidents will surely rely upon to justify more aggressive immigration restrictions," Vladeck said.

However, Vladeck noted that this was the third version of the travel ban and the administration made significant changes in response to lower-court rulings invalidating the first two iterations, including one issued one week after Trump became president in January 2017.

The Supreme Court will wrap up its term Wednesday.

Sotomayor dissent and Korematsu

Justice Sonia Sotomayor, in a blistering dissent, said the court was wrong to ignore Trump's various comments.

"The majority here completely sets aside the President's charged statements about Muslims as irrelevant," she wrote. "That holding erodes the foundational principles of religious tolerance that the court elsewhere has so emphatically protected, and it tells members of minority religions in our country 'that they are outsiders, not full members of the political community.'"

She also compared the opinion to one that came down in 1944 in which the court blessed the internment of Japanese-Americans during World War II.

Reacting to the dissent, Roberts took the unusual step to declare that the 1944 case, Korematsu v. United States, was no longer good law and was wrongly decided. It is the first time the Supreme Court has ever made this public determination.

Liberal lawmakers, groups denounce ruling

Minnesota Democratic Rep. Keith Ellison, the first Muslim elected to Congress, said Tuesday's decision "give legitimacy to discrimination and Islamophobia."

Neal Katyal, one of the lead attorneys for Hawaii in the case said although he was "disappointed" in the court's decision, he argued that the process gives him hope and called on Congress to reverse the President's travel ban.

"While we continue to believe that this third version fails that test, there is no question that by striking down the first two travel bans, the judiciary forced a recalcitrant administration to at least give its order the veil of constitutionality," Katyal said in a statement Tuesday. "We continue to believe, as do four dissenting justices, that the travel ban is unconstitutional, unprecedented, unnecessary and un-American."

The American Civil Liberties Union also strongly condemned the court's ruling, writing on Twitter that "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."

Omar Jadwat, director of the ACLU's Immigrants' Rights Project, said in a statement that the court's "ruling will go down in history as one of the Supreme Court's great failures."

Democratic National Committee chair Tom Perez said, "Discrimination is not a national security strategy, and prejudice is not patriotism. Let's call this ban for what it is: an outright attack on the Muslim community that violates our nation's commitment to liberty and justice for all."

Congressional Republicans applauded the court's decision, arguing that it was a win for national security and dismissing the accusations that it is a ban on Muslims entering the United States.

Republican Sen. Lindsey Graham of South Carolina said he was "pleased."

"As I stated when the new Executive Order was issued, it is not a religious ban," Graham said on Twitter. "The order was focused on countries that are in true states of disarray and would have great difficulty vetting to ensure terrorists are not coming into the United States."

This story is breaking and will be updated.