A federal appeals court has dealt another blow to President Donald Trump's executive order temporarily restricting travel from six Muslim-majority countries.

The Virginia-based 4th Circuit Court of Appeals on Thursday largely upheld a lower court ruling barring the administration from suspending visas from those countries. The Trump administration previously revised the executive order to better hold up to legal scrutiny than an earlier version did.

Trump has insisted that the measure is necessary to prevent possible terrorist attacks and protect national security. But opponents, and courts in previous rulings blocking its enforcement, have cited past statements from Trump and his advisors signaling that it may target Muslims.

The 4th Circuit ruling said it was "unconvinced" that the order "has more to do with national security than it does with effectuating the president's proposed Muslim ban."

Later Thursday, Attorney General Jeff Sessions said in a statement that the Justice Department "strongly disagrees with the decision" and would "seek review of this case in the United States Supreme Court."

Trump had previously said that the federal government will take the case to the Supreme Court, if necessary.

The White House has insisted that Trump had the authority to issue the order based on the president's powers to limit certain immigrants. The 4th Circuit ruling said that while "Congress granted the president broad power to deny entry to aliens," the "power is not absolute."

A federal judge in Hawaii also halted the order, and the Trump administration is fighting that decision in the 9th Circuit Court of Appeals.

The order affects citizens from Iran, Libya, Somalia, Sudan, Syria and Yemen.

Judges have had to consider whether to consider only the text of the executive order or take into account Trump's campaign statements about temporarily barring Muslims from entering the country.

Following the ruling, the White House said it is confident that the "executive order to protect the country is fully lawful and ultimately will be upheld by the Judiciary."

"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," Michael Short, senior assistant press secretary, said in a statement.

"As Judge Shedd's dissent notes, 'the real losers in this case are the millions of individual Americans whose security is threatened on a daily basis by those who seek to do us harm.'"

— NBC News and The Associated Press contributed to this report.