The 10-3 ruling from the 4th US Circuit Court of Appeals upholds a lower court's decision to halt core portions of the executive order indefinitely.

The Trump administration says it plans to appeal to the Supreme Court.

"This Department of Justice will continue to vigorously defend the power and duty of the Executive Branch to protect the people of this country from danger, and will seek review of this case in the United States Supreme Court," Attorney General Jeff Sessions said in a statement.

The ban was announced in March, but never got off the ground because federal courts blocked it just hours before it was set to go into effect. It would have banned people from Iran, Libya, Somalia, Sudan, Syria, and Yemen from entering the US for 90 days and all refugees for 120 days.

The court makes extensive use of Trump's comments during his campaign when he called for a full ban on Muslims from entering the United States as evidence against this executive order.

"The evidence in the record, viewed from the standpoint of the reasonable observer, creates a compelling case that (the executive order's) primary purpose is religious," the ruling states. "Then-candidate Trump's campaign statements reveal that on numerous occasions, he expressed anti-Muslim sentiment, as well as his intent, if elected, to ban Muslims from the United States."

CNN legal analyst and and professor at the University of Texas School of Law Steve Vladeck called the ruling "an enormous victory for the challengers to the travel ban, and a huge loss" for Trump.

Trump campaign statement used against him

This was the Trump administration's second attempt to install a travel ban. The first version, announced in January, also included Iraq.

"In its first test before a federal appeals court, the second, more nuanced version of the Executive Order still failed miserably -- and, once again, largely because of President Trump's own words, tweets, and statements," Vladeck said. "About the only thing the 10 judges in the majority disagreed about was whether President Trump's campaign statements are relevant to his motive -- but even the judges who said no still thought there was enough evidence of discriminatory intent since his inauguration to strike down the ban."

Then-candidate Trump issued a statement calling for the "total and complete shutdown" of Muslims entering the United States until the government could "figure out what is going on," in response to a deadly mass shooting in San Bernardino, California by ISIS sympathizers in December 2015.

Trump later read the plan at South Carolina rally, saying: "We have no choice. We have no choice."

The Muslim ban language was removed one day after oral arguments in the 4th Circuit case.

Page Pate, CNN legal analyst and adjunct professor of law at the University of Georgia, said he believed the attempt to revise the executive order "and make it more constitutional apparently has not worked, at least according to this court."

"I think when they revised this ban, they tried to take that all into accounts, and wisely took out any specific references to religious preferences," Pate said on CNN's "Newsroom," "and I thought that made this ban more likely to be upheld ultimately on appeal because it wasn't as facially as unconstitutional as the first travel ban."

'Justices will have to confront'

The White House said it disagreed with the ruling.

"These clearly are very dangerous times, and we need every available tool at our disposal to prevent terrorists from entering the United States and committing acts of bloodshed and violence," said White House spokesman Michael Short. "We are confident the President's executive order to protect the country is fully lawful and ultimately will be upheld by the Judiciary."

Omar Jadwat, director of the ACLU's Immigrants' Rights Project, cheered the decision.

"President Trump's Muslim ban violates the Constitution, as this decision strongly reaffirms," Jadwat, who argued the case. "The Constitution's prohibition on actions disfavoring or condemning any religion is a fundamental protection for all of us, and we can all be glad that the court today rejected the government's request to set that principle aside."

The 9th US Circuit Court of Appeals is also evaluating the travel ban in a separate appeal. The court has not indicated when it will rule, but the travel ban would not go into effect as long as one nationwide injunction remains in effect.

"It looks increasingly likely that the justices will have to confront the travel ban -- and whether to review today's ruling -- sometime this fall," Vladeck said.

Dissent hits use of Trump campaign quotes

Judge Paul Niemeyer, one of the three dissenters, said the majority "looks past the face" of the executive order.

The approach "adopts a new rule of law that uses campaign statements to recast the plain, unambiguous, and religiously neutral text," Niemeyer, a George W. Bush appointee, wrote. "Opening the door to the use of campaign statements to inform the text of later executive orders has no rational limits."

"Unless corrected by the Supreme Court, the majority's new approach, which is unsupported by any Supreme Court case, will become a sword for plaintiffs to challenge facially neutral government actions, particularly those affecting regions dominated by a single religion," he wrote.

Judge Dennis Shedd, meanwhile, said the executive order doesn't fulfill Trump's stated campaign pledge.

"The President's supposed goal of 'banning Muslims' from the United States is not remotely served by the temporary travel pause, a fact that makes the district court's factual finding even more dubious," Shedd wrote.

The administration did win on one point, Vladeck noted. "The only point on which the majority opinion ruled for the President was that the order blocking the ban could not apply to him, personally, but that's a legal technicality that won't actually matter in practice."