President Donald Trump's revised travel ban just took another hit.

The 9th Circuit Court of Appeals on Monday largely upheld a ruling blocking the president's executive order temporarily restricting travel from six Muslim-majority countries. The decision reviewed a ruling from a Hawaii-based federal judge.

Separately, the Virginia-based 4th Circuit Court of Appeals late last month upheld a Maryland judge's ruling blocking parts of Trump's order.

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 Trump administration has asked the Supreme Court to revive the ban.

Press secretary Sean Spicer said Monday that the White House is confident that the measure is "totally lawful" and will be upheld by the Supreme Court.

In its opinion, the 9th Circuit said it concluded that Trump "exceeded the scope of the authority delegated to him by Congress." The judges also wrote that Trump's order violates provisions that "prohibit nationality-based discrimination and require the president to follow a specific process when setting the annual cap on the admission of refugees."

Trump first signed the executive order on travel in late January. After it was blocked in federal court, the administration crafted a revised version of it to better stand up to legal scrutiny.

The second version has not fared any better in court.

Trump tweeted last week that the measure was a "watered down" version of his original "travel ban." He blamed the Justice Department for not sticking with the "original travel ban."

The court cited one of Trump's tweets in its decision, saying that he highlighted "dangerous" countries targeted by the measure. The judges said Trump characterized the countries as "inherently dangerous," not the people within them.

The White House did not immediately respond to a request to comment on this article.

— Reuters contributed to this report.

Watch: Could Trump's travel ban tweets hit travel stocks?