President Donald Trump capped months of political drama Friday, announcing he's signing a bill to fund the government, avoiding another government shutdown, while also taking the extraordinary action of declaring a national emergency to secure additional money for his proposed border wall that congressional Democrats refused to give him.

"I am going to be signing a national emergency," Trump said.

The president explained his highly controversial move in a Rose Garden announcement, saying "We're going to confront the national security crisis on our southern border and we're going to do it one way or the other."

He said he was taking "critical actions" but "not because it was a campaign promise."

"We're talking about an invasion of our country with drugs, with human traffickers, with all types of criminals and gangs," he explained.

But even as the president sought to cast the situation at the border as a national security and humanitarian crisis, he also made an admission that could be helpful to those mounting legal challenges to his action Friday.

"I could do the wall over a longer period of time. I didn't need to do this, but I'd rather do it much faster," the president said, seeming to concede that a national emergency was avoidable.

The president asserted that he was not declaring an emergency because of the upcoming 2020 election, despite the fact that building a wall was his key campaign promise in 2016, but accused the Democrats of using the issue for campaigning purposes.

"And the only reason we're up here talking about this is because of the election, because they want to try and win an election which it looks like they're not going to be able to do, and this is one of the ways where they think they can possibly win -- is by obstruction and a lot of other nonsense -- and I think that I just want to get it done faster that's all," he said.

As he spoke, White House press secretary Sarah Sanders tweeted out a photo of the president signing the emergency declaration.

Trump's decision to go along with a congressional border security deal funding deal comes after a 35-day shutdown -- the longest in U.S. history -- and after three weeks of negotiations by a bipartisan group on Capitol Hill that delivered a bill without all the wall money the president wanted. The measure includes $1.375 billion for border security, enough to construct about 55 miles of new barrier in new areas, but less than the proposal Trump rejected late last year, triggering the shutdown.

The president's emergency declaration order and other executive actions come on the heels of warnings from the Justice Department that the moves are nearly certain to be blocked by court challenges, at least temporarily.

President Trump directly acknowledged that he expects the emergency order will be challenged in the court system, predicting how the battle will play out and that he will ultimately prevail at the Supreme Court.

"We will have a national emergency and we will then be sued and they will sue us in the Ninth Circuit even though it shouldn't be there, and we will possibly get a bad ruling, and then we'll get another bad ruling, and then we'll end up in the Supreme Court, and hopefully we'll get a fair shake and we'll win in the Supreme Court just like the [travel] ban," Trump said.

Trump is seeking to a total of about $8 billion through a mix of spending from the congressional appropriations bill, executive action and the emergency declaration.

A senior White House official familiar with the plan to get money beyond the congressional funding told ABC News $1.375 billion would come from the spending bill Congress passed Thursday; $600 million would come from the Treasury Department's drug forfeiture fund; $2.5 billion would come from the Pentagon's drug interdiction program; and through an emergency declaration: $3.5 billion from the Pentagon's military construction budget.

Both Republicans and Democrats have voiced opposition to Trump's emergency declaration, a workaround that would allow him to build a border wall without support from Congress.

Senate Majority Leader Mitch McConnell, who had previously opposed the president's moves, announced on the Senate floor Thursday the news that Trump would sign the deal, and that he would support an emergency declaration. on Friday, he, too, blamed Democrats.

“President Trump’s decision to announce emergency action is the predictable and understandable consequence of Democrats’ decision to put partisan obstruction ahead of the national interest," he said in a statement.

House Speaker Nancy Pelosi and Senate Minority Leader Chuck Schumer, in a joint statement issued just after the president's Friday announcement, said, "The President’s unlawful declaration over a crisis that does not exist does great violence to our Constitution and makes America less safe, stealing from urgently needed defense funds for the security of our military and our nation.

"This is plainly a power grab by a disappointed President, who has gone outside the bounds of the law to try to get what he failed to achieve in the constitutional legislative process," their statement continued. "The President's actions clearly violate the Congress’s exclusive power of the purse, which our Founders enshrined in the Constitution. The Congress will defend our constitutional authorities in the Congress, in the Courts, and in the public, using every remedy available. "

ABC News' Jonathan Karl, John Parkinson, Katherine Faulders and Mariam Khan contributed to this report.