U.S. President Donald Trump was slated to sign a government spending and border security plan into law with only hours to spare before parts of the government shut down Saturday. He also declared a national emergency to repurpose funds from other parts of the government to build his proposed border wall without congressional approval.

"I'm going to be signing a national emergency, and it's been signed many times before, by many presidents. It's rarely been a problem ... nobody cared," the president said during unscripted remarks Friday in the White House Rose Garden. White House press secretary Sarah Huckabee Sanders then shared an image that she said showed Trump signing the declaration, according to CNBC.

The president faces significant opposition to his action. The emergency declaration, which was criticized by Democrats and Republicans alike when Trump first threatened it, is likely to bring swift legal and legislative challenges. Already, it has sparked a fierce debate over executive authority, as critics argue Trump has manufactured a crisis to fulfill a campaign promise that was thwarted by Congress.

Trump's comments in recent weeks as he threatened an emergency declaration could hurt his legal case. He repeatedly framed it as a choice, rather than a necessity. On Friday, he claimed, "I could do the wall over a longer period of time. I didn't need to do this [national emergency]. But I would rather do it much faster."

The emergency declaration, the administration claims, would permit the president to divert funds from other agencies, primarily the Department of Defense, to be used for the border project.

Already, some Democrats have threatened legislation to block it. In a joint written statement, House Speaker Nancy Pelosi and Senate Minority Leader Chuck Schumer said they "will defend our constitutional authorities in the Congress, in the Courts and in the public, using every remedy available."

Several Republicans hesitated to line up behind Trump even as the party's leaders backed up the declaration.

Read alsoU.S. senators to try again with tougher Russia sanctions bill – media

In his remarks Friday, Trump justified his move by claiming the U.S. faces an "invasion" — though border crossings are at the lowest levels seen in decades. He argued the U.S. needs barriers to hold off traffickers of people and drugs, even as he commended his administration for stopping so-called caravans of migrants.

Trump braced for a coming legal battle. "I expect to be sued" after declaring an emergency, he said. Trump added that challenges could go to the Supreme Court, where he hopes to get a "fair shake."

"I think we will be very successful in court," the president argued, in response to concerns about his authority to declare a national emergency.