A federal judge in Hawaii on Tuesday blocked President Trump's newest attempt to implement a travel ban, hours before it was scheduled to take effect at midnight.

U.S. District Court Judge Derrick K. Watson issued a temporary restraining order Tuesday on Trump's third executive order, which had banned citizens of eight countries from entering the U.S. because of national security concerns.

The Justice Department said it would appeal the decision.

Related: White House slams 'dangerously flawed' court decision to strike down latest travel ban

"EO-3 suffers from precisely the same maladies as its predecessor: it lacks sufficient findings that the entry of more than 150 million nationals from six specified countries would be 'detrimental to the interests of the United States,' a precondition that the 9th Circuit determined must be satisfied before the executive may properly invoke [his authority to enact the ban]," Watson wrote on Tuesday. "And EO-3 plainly discriminates based on nationality in the manner that the 9th Circuit has found antithetical to both Section 1152(a) and the founding principles of this nation."

The new executive order and guidance, which the Trump administration developed last month, added Chad, Venezuela and North Korea to the list of countries whose citizens may not travel to the U.S. However, only Venezuelan government officials were blocked.

Watson on Tuesday did not make a decision on travel from North Korea and Venezuela because the plaintiffs did not challenge it.

Lower federal courts have blocked all of Trump's attempts to implement the travel ban aimed at various countries of predominantly Muslim populations. The Supreme Court allowed a limited version of the ban to proceed this summer and scheduled arguments in October over the travel ban controversy, which it later rendered moot.

The Supreme Court took the travel ban cases off its calendar after the existing executive order's expiration date passed and the Trump administration developed the new order and new guidance.

The new order, slated to take effect at midnight, is what Watson shot down on Tuesday. Watson's ruling said the plan violated federal immigration law.

The Justice Department said it would appeal the judge's injunction.

"Today's ruling is incorrect, fails to properly respect the separation of powers, and has the potential to cause serious negative consequences for our national security," said Ian Prior, Justice Department spokesman. "The Department of Justice will appeal in an expeditious manner, continue to fight for the implementation of the president's order, and exercise our duties to protect the American people."

The White House has said the affected countries have a way to get off its travel ban list.

"The restrictions being imposed on these eight countries are conditional and may be lifted as they work with the U.S. government to ensure the safety of Americans," a White House statement stated. "We look forward to all countries meeting the new requirements for cooperation with the United States as we continue to take steps necessary to protect our national security."

• Kelly Cohen contributed to this report.